nix, shell, perl, php, mysql and mac os x tips and tricks

Tuesday, November 27, 2012

Cron Job to be texted/emailed when a server has a high load average

You could feasibly add this to your cron tab. Better have an unlimited text plan.
* * * * *       THRESHOLD="10.00"; LOAD=$(/usr/bin/uptime | /bin/awk '{print $8}' | /bin/cut -d "," -f 1;); if /usr/bin/test $(/bin/echo "$LOAD > $THRESHOLD" | /usr/bin/bc -l) = 1 ; then /bin/echo "Load average too high: $LOAD " | /bin/mail -s "calliope load avg: $LOAD" 3304445555@vtext.com; else /bin/echo ""; fi;  > /dev/null 2>&1

No comments:

Post a Comment