It is very important to
check the
disk space usage of different partitions on Linux box.
Any partition run out fo disk space can cause several known and unknown issues.
Following is a
free shell script which can be used in cron to
check the disk usage of partition
and notify by
sending an
alert to provided email ID in script.
Quote:
#!/bin/bash
df -h | grep -v 'Use' | awk '{print $5" : "$6}' | replace '%' '' > /tmp/DiskPercent
for i in `cut -f 1 -d : /tmp/DiskPercent`
do
if [ $i -ge "90" ];
then
echo partition `grep $i /tmp/DiskPercent | cut -f 2 -d :` running out of disk space on `hostname` >> /tmp/disk-overusage
fi
done
if [ -f /tmp/disk-overusage ];
then
mail -s "URGENT `hostname` running out of disk space" support@micfo.com < /tmp/disk-overusage
fi
rm -f /tmp/disk-overusage /tmp/DiskPercent
|
create a file say (/home/disk-usage.sh ) give executable permissions and add in cron to run after particular time intervals (say 3 hours)
The cron would be like this.
Quote:
|
0 */3 * * * /home/disk-usage.sh /dev/null 2>&1
|