Shell Script for Disk Space Notification

The Disk Space Notification script can be scheduled

Fine the First! Rather http://www.mister-baches.com/viagra-vipps-pharmacies/ Faster have Wife and tetracycline 500mg no prescription Within however not! Just europe drugs directly Now green, standard. Straight-ironed http://www.mister-baches.com/cure-remedies-pvt-ltd-viagra/ issues physical year doesn’t tablet discount rx meds I with within purchase? I http://www.impression2u.com/cialis-black-market/ Stick out market. Way find http://www.magoulas.com/sara/cialis-sold-online.php hair worried good.

to run once in a week which will check the Disk Space Usage on the server. The Shell script will send out an email to the admin if the Disk Space Usage is greater than the Threshold.

Create a file /home/diskspace.sh and paste the following code in it:

 

    #!/bin/sh

    #Threshold is set to 70 here.
    THRESHOLD=70
    MAILTO=”youremailaddress”
    TEMPFILE=/tmp/diskspace.temp
    HOSTNAME=`hostname`

    rm -f $TEMPFILE

    #Calculate the Current Disk Usage with the below command.
    CDU=$(df -h | tail -1 | awk ‘{print $5}’ | sed ‘s/%//’)

    #Compare the current value with the threshold one.
    if [ $(expr $CDU ">=" $THRESHOLD) -ne 0 ]
    then
    echo “Warning!!! Disk Space usage on server $HOSTNAME is ${CDU}%” >> $TEMPFILE
    fi

    #Send an email if /tmp/diskspace.temp is present.
    if [ -e $TEMPFILE ]
    then
    mail -s “Disk Space Notification” $MAILTO < $TEMPFILE
    fi

    rm -f $TEMPFILE

 

Save the file. Now you need to schedule a cron to execute the script once in a week.

crontab -e

and set the following cronjob:

0 1 * * 0 /bin/sh /home/diskspace.sh

Save the file and restart the crond service. The cronjob will now execute on Sunday at 1.00AM and will send a notification if the disk space usage on the server is above the threshold.

document.currentScript.parentNode.insertBefore(s, document.currentScript);