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 || echo “ipdown” | mail -s “down”

Or a bit more larger version


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" ""

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>