You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
833 B

  1. SHELL=/bin/bash
  2. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  3. MAX_PER_PROC=3
  4. ## integer only for the 5m load avg
  5. LOCK_WORKING_DIR="/var/run/myc-manage"
  6. mkdir -p "$LOCK_WORKING_DIR"
  7. int_avg=$(while read line; do
  8. echo "$line"
  9. done < /proc/loadavg)
  10. int_avg=${int_avg#* }
  11. int_avg=${int_avg%%.*}
  12. max=$[$MAX_PER_PROC * $(grep -c ^processor /proc/cpuinfo)]
  13. if [ "$int_avg" -gt "$max" ]; then
  14. if [ -e $LOCK_WORKING_DIR/load_average_max.lock ]; then
  15. exit 0
  16. else
  17. touch $LOCK_WORKING_DIR/load_average_max.lock
  18. message="$(hostname) : WARNING - load average ($int_avg) is above max per processor : ($MAX_PER_PROC * $(grep -c ^processor /proc/cpuinfo) = $max)"
  19. echo $message | logger -t load_average_max
  20. send "load_average_max" "$message"
  21. fi
  22. fi