Advertisement
se7enuts

222

May 30th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #http://i.imgur.com/C4xLUD5.png
  2. #!/bin/sh
  3.  
  4. if [ $# -ne 2 ] ; then
  5. echo "reikalingi 2 parametrai"
  6. exit 1
  7. fi
  8. if [ ! -d $1 ]; then
  9. echo "pirmas argumentas turi buti katalogas"
  10. exit 1
  11. fi
  12.  
  13. filelist=$(ls -l "$1" | grep sa_ | awk '{print $9}') #get only sa_ files and get their names
  14.  
  15. for file in $filelist; do
  16. path=$(echo $1"/"$file)
  17. cnt=$(wc -l "$path" | awk '{print $1}')
  18. min=$(sar -u -f "$path" | tail +5 | grep ^[0-9] | awk 'BEGIN{min=100;}{min=(min > $5)?$5:min;}END{print min;}')
  19. max=$(sar -u -f "$path" | tail +5 | grep ^[0-9] | awk 'BEGIN{max=0;}{max=(max < $5)? $5 : max;}END{print max;}')
  20. echo $path " min="$min " max="$max
  21. ltcnt=$(sar -u -f "$path" | tail +5 | grep ^[0-9] | awk -v arg=$2 'BEGIN{count=0;}{if( $5 < arg ){count++}}END{print count}')
  22. if [ $ltcnt -ne 0 ]; then
  23. sar -u -f "$path" | tail +4 | grep ^[0-9] | awk -v arg=$2 '{if( NR == 1 ){print $0}else if($5 < arg){print $0 " < " arg}}'
  24. fi
  25. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement