checkLoad.sh 460 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. # Bail if the load average is high
  3. LOAD="`uptime | awk -F ': ' '{print $2}' | cut -d '.' -f 1`"
  4. if [ -r /proc/cpuinfo ]; then
  5. CPU_COUNT="`cat /proc/cpuinfo | awk '$1 == "processor" {print $3}' | sort | tail -n 1`"
  6. else
  7. CPU_COUNT="`sysctl -n hw.ncpu`"
  8. fi
  9. if [ $LOAD -gt $(( 2 * $CPU_COUNT )) ]; then
  10. exit 1
  11. fi
  12. # Bail if WoW is running
  13. if ps auwx | grep -v grep | grep -q "World of Warcraft-64"; then
  14. exit 1
  15. fi
  16. # Otherwise exit cleanly
  17. exit 0