Earlier this week I wrote about using sSMTP as a simple way to send email from a system. The goal I had in mind was being notified when my web server is under a lot of load or goes down.

This week I wrote a script in Python, servermonitor2.py, to do just this. In case anyone else is interested in this, I’ll post it here:
Download servermonitor2.tar.gz

The script works in two parts. The main python script runs on your local computer. The simple PHP script runs on the web server, it just prints the output of free -m and uptime.

The python script periodically downloads this output and checks the free memory, swapped memory, and load average. If the download fails, or any of these checks are within defined warning zones, an email will be sent with sSMTP.

There’s an options section at the beginning of the python script for setting up the email addresses, the URL of the PHP script, the warning zones, and the time between checks.

Leave a comment, or email me (my address is here) if you have a bug, question, comment or suggestion. I’m new to programming, so I’d also like to hear any critiques on the code.


Related Posts