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.

28 lines
846 B

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