#!/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 Admin" >> $EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
fi
Note: You can deploy this script as follows
1. create a file loadchecker with the above content.
2. give the execute permission by chmod +x loadchecker .
3. Enter the script in crontab.
Add the line for executing the script for every 2 minutes.
*/2 * * * * /root/loadchecker
If you don't know what value to set as threshold please go through the link Understanding Load Average
Happy Shooting ;-)
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 Admin" >> $EMAILMESSAGE
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
fi
Note: You can deploy this script as follows
1. create a file loadchecker with the above content.
2. give the execute permission by chmod +x loadchecker .
3. Enter the script in crontab.
Add the line for executing the script for every 2 minutes.
*/2 * * * * /root/loadchecker
If you don't know what value to set as threshold please go through the link Understanding Load Average
Happy Shooting ;-)
Comments