SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin MAX_PER_PROC=3 ## integer only for the 5m load avg int_avg=$(while read line; do echo "$line" done < /proc/loadavg) int_avg=${int_avg#* } int_avg=${int_avg%%.*} max=$[$MAX_PER_PROC * $(grep -c ^processor /proc/cpuinfo)] if [ "$int_avg" -gt "$max" ]; then if [ -e /tmp/load_average_max.lock ]; then exit 0 else touch /tmp/load_average_max.lock message="$(hostname) : WARNING - load average ($int_avg) is above max per processor : ($MAX_PER_PROC * $(grep -c ^processor /proc/cpuinfo) = $max)" echo $message | logger -t load_average_max send "load_average_max" "$message" fi fi