17 May, 2012

Server uptime monitoring

For a while now I had wanted to monitor in real time my web server's availability.  But how?  Anything on the server itself would fail - because, if the server was down, the script would not work. After the event, the logs would show what's happened of course; but I wanted instant notification of a problem. Lots of companies offer this service at a price.  I wanted it free!  The solution turns out to be quite simple.  Sign up to a free web server service.  I picked http://www.000webhost.com/ and created a script on that machine that runs every five minutes to look up a small file on my main server.  If it fails to find the file, the script sends me an alert email.  This does generate the occasional 'false negative' but that is better than the main site being down for hours unbeknown to me.  If the script is successful this is recorded on a database.  Once a day the script records the stats for day, purges the database table and sends me a summary.  I think that is quite neat...