Email alert on disk space outage in linux

For Send mail Tutorial Click Here

Need to be installed sendmail ( yum install sendmail) and mailx (yum install mailx)

Create a shell script in linux.

vi diskalert.sh

#!/bin/sh
support=”itsupport@xyz.com”
# set alert level 90% is default
ALERT=90
df -HP | grep -vE ‘^Filesystem|tmpfs|cdrom’ |
  while read partition size used free perc mnt ;
  do
    usep=$(echo $perc | tr -d ‘%’ )
    if [ $usep -ge $ALERT ]; then
      echo “Running out of space “$partition ($usep%)” on $(hostname) as
  on $(date)” |
       mail -s “Alert: Almost out of disk space – $usep%” $support
    fi
  done
Now make this script executable as below.
chmod 777 diskalert.sh
and now set the cron job as follows.
0 09 * * * /diskalert.sh

 

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

26 thoughts on “Email alert on disk space outage in linux

Leave a Reply