Sunday 26 February 2017

Diskspace monitoring script for Sys Admins


#!/bin/sh
df -H |  grep -v 'Filesystem' | awk '{ print $5 " " $1 }' | while read output
do
   usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1  )
   echo $usep
   partition=$(echo $output | awk '{ print $2 }' )
   echo $partition
   if [ $usep -ge 90 ]
   then
echo "sapce has reached the limit"
#send mail utility can be downloaded from google and change the values according to your SMTP server
sendEmail -bcc mail_id_of_team -u Disk Space Status Notification : `hostname` -o message-content-type=html -m "Disk Space Status Notification : `hostname` <br/><br/><table border=\"1\"><tr><td><strong>HOSTNAME</strong></td><td><strong>HEALTH</strong></td><td><strong>FILE SYSTEM</strong></td></tr><tr><td>`hostname`</td><td>$usep%</td><td>$partition</td></tr></tr></table><br/><br/>please take action immediately"

  fi
done

No comments:

Post a Comment