Posts Tagged ‘monitor’


This will monitor the Disk space of a Linux system and send an email to ADMIN . Admin , and Thresold is a variable , so that it can be change accordingly.

===================================================

#!/bin/bash
#       This script determines the percentage of disk usage.
#       If that percentage is greater than 90% a user is emailed
#       a report notifying them of the usage.
#

emailUser=”it.support@au.specsavers.com,brandont@au.specsavers.com”
typeset -i error=”70″
if [ -e temp.txt ]; then
rm temp.txt
fi
for disc in `mount| egrep ‘^/dev’ | egrep -iv ‘cdrom|proc|sys|pts’ |awk ‘{print $3}’`
do
typeset -i discUsage=`df -h $disc|cut -c40-42|grep -i [^a-z]`
if [ “$discUsage” -ge “$error” ]; then
echo “Disc usage for $disc is at $discUsage. Need your attention !!%” >> temp.txt
fi
done
if [ -e temp.txt ]; then
message=`cat temp.txt`
fi
if [ ${#message} -gt 0 ]; then
cat temp.txt | mail  -s “Disc Usage exceed 70% for : $HOSTNAME” $emailUser
fi

===================================================