Full Disk Check - Notify

Another stupid little script written with the same principle as the previous ones to notify the administrator when a drive reaches 99% usage.

FULL_DRIVES=`df -h | grep "99%"`
SPACE_USE=`echo $FULL_DRIVES | awk '{print $5}'`
PERCENT=`echo ${SPACE_USE%%%}`

if [ "$PERCENT" = "99" ]
wget "http://api.clickatell.com/http/auth?api_id=yourapi_id&user=usrname&password=passwd" -O /tmp/sessionid -q
# Create session and save to /tmp/sessionid
sessionid=`cat /tmp/sessionid | awk '{print $2}'`
# use only the session id for the variable
smssend clickatell.sms $sessionid usrname passwd yourapi_id "SystemAlert" phoneNo "$FULL_DRIVES"
# send sms
echo "No disks have reached critical usage"

The previous articles can be found here and here

Thanks for playing :)

Popular Posts