Option 1: Write a script that runs df, parses the output for the percent utilization & sends an email when it exceeds a given threshold, then run this script from cron.
(If you're feeling lazy you can find a bunch of pre-written scripts by asking The Knower of All Things for Unix Disk space check script.)
Option 2 (The better solution):
Deploy a monitoring system (Nagios, InterMapper, OpenNMS, etc. -- look around here for lots of suggestions & opinions), and configure it to send you a notification when your disks are filling up. While you're at it configure alerts for other stuff you might be concerned about :-)
For people who do not have a monitoring system, this simple script can do the job :
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=90
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert' [email protected] << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
+1 for option 2 above.
You may think you only need to monitor disk space right now, but the reality is you almost certainly need monitoring for more than one or two servers. It will benefit you in ways that will amaze you long term.
I'd personally recommend Zenoss, it's F/LOSS, relatively easy to setup and get going, and they have great documentation.
Option 1:
Write a script that runs
df
, parses the output for the percent utilization & sends an email when it exceeds a given threshold, then run this script from cron.(If you're feeling lazy you can find a bunch of pre-written scripts by asking The Knower of All Things for
Unix Disk space check script
.)Option 2 (The better solution):
Deploy a monitoring system (Nagios, InterMapper, OpenNMS, etc. -- look around here for lots of suggestions & opinions), and configure it to send you a notification when your disks are filling up. While you're at it configure alerts for other stuff you might be concerned about :-)
One point for solution 2 too ! I recommend you the "Monit" software that is very light and easy to configure : http://mmonit.com/monit/
For people who do not have a monitoring system, this simple script can do the job :
Then just add a cron job.
+1 for option 2 above. You may think you only need to monitor disk space right now, but the reality is you almost certainly need monitoring for more than one or two servers. It will benefit you in ways that will amaze you long term.
I'd personally recommend Zenoss, it's F/LOSS, relatively easy to setup and get going, and they have great documentation.