Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #!/bin/bash
  2. nPid=${1-`pgrep -f ossec-remoted`}
  3. nTimes=${2:-100}
  4. delay=${3:-0.1}
  5. strCalc=`top -d $delay -b -n $nTimes -p $nPid \
  6. |grep $nPid \
  7. |sed -r -e "s;\s\s*; ;g" -e "s;^ *;;" \
  8. |cut -d' ' -f9 \
  9. |tr '\n' '+' \
  10. |sed -r -e "s;(.*)[+]$;\1;" -e "s/.*/scale=2;(&)\/$nTimes/"`;
  11. nPercCpu=`echo "$strCalc" |bc -l`
  12. total_time=$(perl -e "print ${delay}*${nTimes}" )
  13. total_active=$(/var/ossec/bin/agent_control -lc| wc -l)
  14. total_configured=$(/var/ossec/bin/agent_control -l|wc -l)
  15. total_file_opened=$(lsof -p $nPid |wc -l)
  16. echo "
  17. {
  18. 'pid': $nPid,
  19. 'average': $nPercCpu,
  20. 'capture_frequency': $nTimes,
  21. 'delay': $delay,
  22. 'total_time': $total_time,
  23. 'total_active': $total_active,
  24. 'total_configured': $total_configured,
  25. 'total_files_opned_by_process': $total_file_opened
  26. }
  27. "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement