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

 

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

  1. Hello would you mind sharing which blog platform you’re using?
    I’m looking to start my own blog in the near
    future but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most
    blogs and I’m looking for something completely unique.
    P.S Apologies for getting off-topic but I had to ask!

  2. I am curious to find out what blog system you’re working with?
    I’m having some small security issues with my latest website and I’d like to find something more safe.
    Do you have any suggestions?

  3. My spouse and I absolutely love your blog and find almost
    all of your post’s to be exactly what I’m looking for.
    Does one offer guest writers to write content to suit your needs?
    I wouldn’t mind producing a post or elaborating on a number
    of the subjects you write concerning here. Again, awesome website!

Leave a Comment