#!/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
