Board index Linux Shell Scripts

Moderator: chandranjoy

Diskspace Alert Script

Postby chandranjoy » Sat Dec 18, 2010 4:54 pm

Diskspace Alert Script:

Code: Select all
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
  echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 }' )
  if [ $usep -ge 80 ]; then
    echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
     mail  -s "Alert:Almost out of disk space $usep%" yourmail@blahblah.com
fi
done


Enjoy :)
chandranjoy
Site Admin
 
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to Shell Scripts

Who is online

Users browsing this forum: No registered users and 1 guest


cron