Python Server Monitoring Scripts

2011-05-09

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.

Configuration

Create a conf.py containing these settings:

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

Get the code

https://gist.github.com/gregplaysguitar/961724