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 servermonkey
by hanes_ray
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 hanes_ray
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.
by hanes_ray
by hanes_ray
This discussion is closed to new replies.
Trending Linux posts
Sort by Trending