ソースを参照

Support linux

Zachary Kotlarek 12 年 前
親
コミット
1b05ef5901
1 ファイル変更、5 行追加、1 行削除
  1. 5 1
      checkLoad.sh

+ 5 - 1
checkLoad.sh

@@ -2,7 +2,11 @@
 
 
 # Bail if the load average is high
 # Bail if the load average is high
 LOAD="`uptime | awk -F ': ' '{print $2}' | cut -d '.' -f 1`"
 LOAD="`uptime | awk -F ': ' '{print $2}' | cut -d '.' -f 1`"
-CPU_COUNT="`sysctl -n hw.ncpu`"
+if [ -r /proc/cpuinfo ]; then
+	CPU_COUNT="`cat /proc/cpuinfo | awk '$1 == "processor" {print $3}' | sort | tail -n 1`"
+else
+	CPU_COUNT="`sysctl -n hw.ncpu`"
+fi
 if [ $LOAD -gt $(( 2 * $CPU_COUNT )) ]; then
 if [ $LOAD -gt $(( 2 * $CPU_COUNT )) ]; then
 	exit 1
 	exit 1
 fi
 fi