Python Server Monitoring Script

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.

Conf

Create a conf.py containing these:

SERVER_NAME = 'My Server'
EMAIL_HOST = 'localhost'
FROM_EMAIL = 'root@myserver.com'
RECIPIENTS = ['me@example.com']
LOG_DIR = '~/log'

Usage

Add these to your crontab:

*          *  *   *   *     free -m | /path/to/memory_monitor.py
45         *  *   *   *     df -h | /path/to/disk_monitor.py

Download

Get the code here: https://gist.github.com/961724


Loading