Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.62 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. if [ $# -ne 2 ]; then
  4.     echo "wrong"
  5.     exit
  6. fi
  7. cpulimit=$1
  8. memlimit=$2
  9. osd_prop='-c blue -f -*-helvetica-bold-r-*-*-34-*-*-*-*-*-*\
  10.              -p middle -A center -d 2 --shadow=1'
  11.  
  12. while(:); do
  13.     cpuguys=`top -b -n1 | awk '$9>'$cpulimit' && NR > 5{ print $12 }'`
  14.     memguys=`top -b -n1 | awk '$10>'$memlimit' && NR > 5{ print $12 }'`
  15.     for d in $cpuguys; do
  16.         print `echo $d 'is taking more than ' $cpulimit '% cpu power'\
  17.                  | osd_cat  $osd_prop`
  18.         sleep 3
  19.     done
  20.     for d in $memguys; do
  21.         print `echo $d 'is using more than ' $memlimit '% of your memory'\
  22.                  | osd_cat  $osd_prop`
  23.         sleep 3
  24.     done
  25.     sleep 60
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement