Simple Python Script to Monitor Your Web Server

Too cheap to get a proper monitoring tool? Here’s a simple Python script that I wrote that will send me an email if my webserver isn’t returning HTTP 200.

  1. git clone
  2. Open with your favourite text editor.
  3. Change the EMAIL_LIST variable, SERVER and FROM variable.
  4. On line 36 and 37, change your webserver address and the email subject and message.
  5. Copy to your webserver
  6. Add the script to your crontab by typing sudo crontab -e
  7. To run the script every 5 minutes, enter */5 * * * * /<your path>/

Note: I’ve only tested this script on Python 2.6 (since my server came with that version of Python). I’m not sure if it’ll work on Python 3.

Copyright © 2016 - Benson Lim -