droidzone

Check process

Jul 5th, 2013
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. NOTIFY="3.0"
  3. FTEXT='load average:'
  4. F5M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f1 | sed 's/ //g')"
  5. F10M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f2 | sed 's/ //g')"
  6. F15M="$(uptime | awk -F "$FTEXT" '{ print $2 }' | cut -d, -f3 | sed 's/ //g')"
  7.  
  8. if [ $F15M -gt $NOTIFY ]
  9. then
  10.     EMAIL="youremail@email.com"
  11.     SUBJECT="Alert $(hostname) load average"
  12.     TEMPFILE="$(mktemp)"
  13.     echo "Load average Crossed allowed limit $NOTIFY." >> $TEMPFILE
  14.     echo "Hostname: $(hostname)" >> $TEMPFILE
  15.     echo "Local Date & Time : $(date)" >> $TEMPFILE
  16.     #Write to cron log.
  17.     echo "Load average crossed set limit. Admin mailed."
  18.     mail -s "$SUBJECT" "$EMAIL" < $TEMPFILE
  19.     rm -f $TEMPFILE
  20. fi
RAW Paste Data