Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- nPid=${1-`pgrep -f ossec-remoted`}
- nTimes=${2:-100}
- delay=${3:-0.1}
- strCalc=`top -d $delay -b -n $nTimes -p $nPid \
- |grep $nPid \
- |sed -r -e "s;\s\s*; ;g" -e "s;^ *;;" \
- |cut -d' ' -f9 \
- |tr '\n' '+' \
- |sed -r -e "s;(.*)[+]$;\1;" -e "s/.*/scale=2;(&)\/$nTimes/"`;
- nPercCpu=`echo "$strCalc" |bc -l`
- total_time=$(perl -e "print ${delay}*${nTimes}" )
- total_active=$(/var/ossec/bin/agent_control -lc| wc -l)
- total_configured=$(/var/ossec/bin/agent_control -l|wc -l)
- total_file_opened=$(lsof -p $nPid |wc -l)
- echo "
- {
- 'pid': $nPid,
- 'average': $nPercCpu,
- 'capture_frequency': $nTimes,
- 'delay': $delay,
- 'total_time': $total_time,
- 'total_active': $total_active,
- 'total_configured': $total_configured,
- 'total_files_opned_by_process': $total_file_opened
- }
- "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement