The "df" (diskfree) command is provided just for monitoring drive space.
If you are working with a Sys-V-based system, or some Berkeley-based systems,
you have access to a script called "dfspace" that massages the output of df.
A sample of dfspace's output:
/ : Disk space: 836.00 MB of 1610.99 MB available (51.89%)
/stand : Disk space: 1.70 MB of 8.00 MB available (21.30%)
/usr/Xmore : Disk space: 27.85 MB of 300.00 MB available ( 9.29%)
/usr/mount1 : Disk space: 146.61 MB of 437.50 MB available (33.51%)
/usr/mount2 : Disk space: 75.65 MB of 379.39 MB available (19.94%)
/usr/mount3 : Disk space: 160.68 MB of 903.32 MB available (17.79%)
/usr/mount4 : Disk space: 661.09 MB of 830.07 MB available (79.64%)
/usr/mount5 : Disk space: 313.73 MB of 610.35 MB available (51.40%)
/usr1 : Disk space: 20.42 MB of 195.31 MB available (10.46%)
The simplest thing you can do is to run this as a cron job that will email
you the results to check manually. As root, create a cron entry by running
"crontab", and add a line like:
15 1,7,13,19 * * * '/sbin/dfspace |mailx -s "disk space report" root'
(this runs it at: 01:15, 07:15, 13:15 and 19:15 everyday)
What would be really nice is to notify youself if a disk is filling up
automatically. Since dfspace is a shell script, you could copy it and modify
it to your own needs. Or you could create a wrapper script like the following:
# script to notify root if a disk (mounted system) is getting full
THRESHOLD=10 # what integer percentage under which to notify
TMPFILE=/tmp/{$0}_tmpfile
OK_TST=true
dfspace |while read LINE; do
MNT_NM=`echo $LINE |cut -d\: -f1`
if [ "$MNT_NM" = "" ]; then continue; fi
PCT_FULL=`echo $LINE |cut -d\( -f2 |cut -c1-5`
INT_FULL=`echo $PCT_FULL |cut -d. -f1`
TST_VAL=`expr $INT_FULL - $THRESHOLD`
if [ $TST_VAL -lt 0 ]; then
OK_TST=false
echo "$MNT_NM: $PCT_FULL is below $THRESHOLD.00%" >> $TMPFILE
fi
done
if [ "$OK_TST" = "false" ]; then
{
echo "The following mounted filesystems are dangerously low on space:\n"
cat $TMPFILE
echo "\nA total space utilization report follows:\n"
dfspace
} | mailx -s "low filesystem report" root
fi
rm $TMPFILE 2>/dev/null
exit 0
This generates an email message like the following:
+ From root Tue Aug 15 14:02 EDT 1995
+ Date: Tue, 15 Aug 95 14:02 EDT
+ From: Super User <r...@system.domain>
+ To: root
+ Subject: low filesystem report
+ Content-Length: 1416
+ Content-Type: text
+
+ The following mounted filesystems are dangerously low on space:
+
+ /usr/Xmore : 9.29 is below 10.00%
+ /usr/mount7 : 7.68 is below 10.00%
+
+ A total space utilization report follows:
+
+ / : Disk space: 833.47 MB of 1610.99 MB available (51.74%)
+ /stand : Disk space: 1.70 MB of 8.00 MB available (21.30%)
+ /usr/Xmore : Disk space: 27.85 MB of 300.00 MB available ( 9.29%)
+ /usr/mount1 : Disk space: 146.61 MB of 437.50 MB available (33.51%)
+ /usr/mount2 : Disk space: 75.65 MB of 379.39 MB available (19.94%)
+ /usr/mount3 : Disk space: 149.09 MB of 903.32 MB available (16.51%)
+ /usr/mount4 : Disk space: 661.09 MB of 830.07 MB available (79.64%)
+ /usr/mount5 : Disk space: 311.53 MB of 610.35 MB available (51.04%)
+ /usr1 : Disk space: 20.42 MB of 195.31 MB available (10.46%)
+ /usr/mount6 : Disk space: 73.97 MB of 601.37 MB available (12.30%)
+ /usr/mount7 : Disk space: 26.49 MB of 345.00 MB available ( 7.68%)
+ /usr/add-on/pubtools: Disk space: 153.93 MB of 470.53 MB available (32.72%)
+ /var/news : Disk space: 26.09 MB of 49.99 MB available (52.20%)
+ /usr/add-on/utils : Disk space: 153.93 MB of 470.53 MB available (32.72%)
+
+ Total Disk Space: 2661.91 MB of 7212.39 MB available (36.91%).
Then just run the new script from cron every so often.
I hope all of this helps...
--
- sgh What are you doing, reading the words at the bottom?!? Key Grip!?!
What is a key grip anyway?! I don't give credit to anybody -- it's
Scott G. Hall (s...@cbgbcs.cb.att.com) all my show!! - Duckman
AT&T Bell Laboratories - GCBS, Columbus, OH, USA