This is a quick script, intended to be run regularly via cron, which will check selected file systems and ensure the usage does not exceed 95%.
To customise this for a different site: change the for loop parameter to a list of appropriate filesystems; change the MAILLIST variable to a suitable recipient(s); and set the LIMIT variable to a different value if necessary.
#!/bin/sh
#
# Disk Space Monitor
#
WARNING=0
LIMIT=95
MESSAGE=/tmp/dsmon.$$
MAILLIST=unix.administrator@example.co.uk
for fs in /disk0[12348]; do
used_num=`df -k $fs | awk '{print $5}' | sed -e 's/capacity//' -e 's/%//'`
if [ $used_num -ge $LIMIT ]; then
eek="EEEK!"
WARNING=1
df -k $fs >> $MESSAGE
else
eek="OK"
fi
done
if [ $WARNING -eq 1 ]; then
mailx -s "`hostname` disk space alert" $MAILLIST << EOF
The following file systems are dangerously full
`cat $MESSAGE`
Please rectify ASAP.
EOF
fi
script goes here