Discussion Locked

Monitoring Disk Space

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is there a good utility out there for monitoring disk space. Since linux doesn't warn you I'd like something that will tell me when a systems disk is full.

10 replies

by woody

cron will send you (root) any output from scripts run by cron. (No output, no report) So create a script (diskcheck.sh) in /etc/cron.daily and put in it:
#!/bin/sh
# Get the remaining percent of drive space and
# report if it is below the warning threshhold

# Percent space remain threshold (integer with NO '%' sign
WARNLVL=15
# Space delimited list of drives to check. eg: "/ /var /home"
DRIVELIST="/ /home"

WARNING=""
for DRIVE in $DRIVELIST ; do
PCT=`df -h $DRIVE | grep -v Filesystem | sed 's@[[:space:]]\{1,\}@ @g' | cut -d \ -f5 | sed s@%@@`
if (($PCT < $WARNLVL)) ; then
WARNING="$WARNING$DRIVE is low on space! ($PCT Remaining) "
fi
done

if [ "$WARNING" != "" ]; thenecho $WARNING
fi
# End script

Do not forget to set the script executable:
chmod 755 /etc/cron.daily/diskcheck.sh

by woody

the PCT=`...` line should be all on one line to the final @ symbol with its trailing back tick (`)

by jerome

in addition to woody's script i suggest adding
this line..

mail your_email_addr < $VAR_THAT_HOLDS_RESULT

this would eliminate the user to constantly
executing the script... and would just wait for
the mail every morning...

hmm.. and one more thing it would be best if it
would mail the disk space status without any
constraint.. no more warning level..

by mtuppen

We use Big Brother (from bb4.com) to monitor our servers - including disk space. This would be overkill for just 1 server, but it is great for monitoring many servers.

If you wanted to, you could also look for a linux disk checking solution at freshmeat.net

Regards,
Mike.

This discussion is closed to new replies.