Created
October 4, 2012 18:18
Revisions
-
scorpio2k2 created this gist
Oct 4, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/bin/sh #The limit is 30% now limit=10 mail=contact@debian-tutorials.com tmp_file=/tmp/diskusage hostname=`hostname` #Now the script will calculate the current disk usage disk=$(df -h | head -2 | tail -1 | awk '{print $5}' | sed 's/%//') #Now the script will compare the current value with the limit if [ $(expr $disk ">=" $limit) -ne 0 ] then echo "Your Disk space limit is set to: $limit %" > $tmp_file echo "Occupied space on the server is: $disk %" >> $tmp_file echo "Notification!!! Disk Space Usage on server $hostname exceeded the limit." >> $tmp_file fi #Now we send the notification if [ -e $TEMPFILE ] then mail -s "IMPORTANT!!! Disk Space Notification" $mail < $tmp_file fi exit 0