Python Server Monitoring Scripts
A couple of simple scripts to keep an eye on memory and disk usage on a Linux server - tested and in use on Ubuntu 8.04 and 10.04, but should be useful on various other platforms. The end result should be a text log of memory and disk status, with warning emails whenever things get a bit tight. The scripts work by periodically parsing the output of the free and df commands.
Create a conf.py containing these settings:
SERVER_NAME = 'My Server' EMAIL_HOST = 'localhost' FROM_EMAIL = 'firstname.lastname@example.org' RECIPIENTS = ['email@example.com'] LOG_DIR = '~/log'
Add these to your crontab:
* * * * * free -m | /path/to/memory_monitor.py 45 * * * * df -h | /path/to/disk_monitor.py