It is very critical that you keep monitoring disk spaces so you can install additional hard disk or remove the un-necessary file from hard disk in order to free up some space.
Below given script will monitor hard disk space and when it detects that hard disk is used around 70 % then it generate an email alert at specified email address.
df -h | grep -v ‘Use’ | awk ‘{print $5″ : “$6}’ | replace ‘%’ ” > /tmp/diskfile
for i in `cut -f 1 -d : /tmp/diskfile`
do
if [ $i -ge "70" ];
then
echo partition `grep $i /tmp/diskfile| cut -f 2 -d :` Critical disk space on `hostname` >> /tmp/disk-overusage
fi
done
if [ -f /tmp/disk-overusage ];
then
mail -s “URGENT `hostname` running out of disk space” test@test.com < /tmp/disk-overusage
fi
rm -f /tmp/disk-overusage /tmp/diskfile
Wednesday, February 3, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment