Disk space usage alert script - Linux

The disk space usage script is created to check the disk space usage and send alerts when disk space usage is critical.

#Purpose: Script to check disk space usage and send alert on critical usage.
#Created by: Abhijit Sandhan
#####################################################
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output;
do
#echo $output
usage=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usage -ge 90 ]; then
echo "Running out of space \"$partition ($usage%)\" on $(hostname) as on $(date), please check!" |
mail -s "Alert: partition \"$partition\" almost out of disk space $usage%" email@example.com
fi
done

In the above disk space usage script,
One should modify the partitions wish to monitor as it varies from server to server.
The critical usage value is set to 90% to send alerts. One may modify the usage value as per the requirement.

Hope this helps!

The disk space usage script is created to check the disk space usage and send alerts when disk space usage is critical. #Purpose: Script to check disk space usage and send alert on critical usage. #Created by: Abhijit Sandhan ##################################################### df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output; do #echo $output usage=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo $output | awk '{ print $2 }' ) if [ $usage -ge 90 ]; then echo "Running out of space \"$partition ($usage%)\" on $(hostname) as…

Review Overview

User Rating: Be the first one !
Share on Facebook3Share on Google+0Tweet about this on TwitterShare on StumbleUpon0Share on LinkedIn5Share on Tumblr0Pin on Pinterest0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing Knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *