Check if a server is down and email admin

A simple shell cronjob to mail the admin when a particular ip is down.

ping -c 1 192.168.0.99 || echo “ipdown” | mail -s “down” jebasingh.emmanuel@gmail.com

Or a bit more larger version

PINGCOUNT=4
IPADDR="192.168.0.59"

COUNT=`ping -c $PINGCOUNT $IPADDR|grep 'received'|awk -F ',' '{print $2}'|awk '{print $1}'`
if [ $COUNT -eq 0 ]; then
  echo "Ping reported no responses from $IPADDR over $PINGCOUNT pings."|mail -s "Ping Failure" "jebasingh.emmanuel@gmail.com"
fi