Skip to main content

Posts

Showing posts from June 14, 2013

Script to check the load and email you the details if the load is greater than given threshold.

#!/bin/bash LoadFloat=$(uptime | gawk -F 'load average:' '{print $2}' | awk '{print $1}' | sed -e 's/,//g') Load=${LoadFloat/\.*} LoadLimit=6 # This is the Load threshold that is to be set by your server requirements. if [ $Load -lt $LoadLimit ] then exit 1 else echo "Load is High " $Load # email subject SUBJECT="LOAD is $LoadFloat in CP6!!!" # Email To ? EMAIL="9207421@way2sms.com" # Email text/message EMAILMESSAGE="/tmp/emailmessage.txt" echo "Hi Team, " > $EMAILMESSAGE echo " " >> $EMAILMESSAGE echo " " >> $EMAILMESSAGE echo "The Load in CP6 is $LoadFloat">> $EMAILMESSAGE echo "Please Login and Have a check Immediately!!!!" >>$EMAILMESSAGE echo " " >> $EMAILMESSAGE echo " " >> $EMAILMESSAGE echo "Regards," >> $EMAILMESSAGE echo "System Ad