Many times I came across the problem, that when you need to instantly monitor the load average of your servers it is not very comfortable to stare at the console. Especially when you need to know what was going on when you were sleeping . So I wrote a very basic script for monitoring purposes. When load average is higher than it should be an email notification will be sent to specified address. Feel free to modify it .
Code:
#!/bin/sh
MAX_LAVG=1 #set the MAX load average value
EMAIL=your@email.here #set the email to send the notification
INTERVAL=30 #set the time interval in seconds to check the load average value
while sleep $INTERVAL
do
LAVG=$(uptime | awk '{gsub(",",""); print $10}')
MLAVG=`echo $LAVG|awk -F \. '{print $1}'`
if [ "$MLAVG" -ge "$MAX_LAVG" ]; then
SUBJECT="$(hostname) LOAD AVERAGE ALERT $LAVG (>$MAX_LAVG)"
EMAILMESSAGE="WARNING! Load average is $LAVG an is more than $MAX_LAVG on $(date)"
echo $EMAILMESSAGE | mail -s "$SUBJECT" "$EMAIL"
fi
done