Simple web server monitoring (alive)

You can use wget in a script like this

wget --timeout=3 --tries=1 --spider --no-check-certificate http://serverfault.com

if [ $? -ne 0 ];then
  echo "Site Down" | mail -s "Site Down" [email protected]
fi

And you will get an email if wget cannot access the site first time within three seconds.

Set up a cron job to run the script every few minutes.

There are many other alternatives but this is probably the simplest to set up from scratch.


You have many options, I'll give you two.

  • Nagios is a full-blown monitoring application capable of monitoring much much more than http, but it handles that as well. It can also create all kinds of repots ("Tell me the uptime percentage of our server/service X this week/month/year...")

  • Monit is another popular choice. Maybe not as feature-filled as Nagios, but nevertheless it's nice.