重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
cat check_xen_temp.sh #!/bin/bash ipmitool sensor | gawk -F'|' ' BEGIN { EXIT=0; MSG[0]="OK: "; MSG[1]="WARNING: "; MSG[2]="CRITICAL: "; perf=""; } { gsub(/\t/," "); gsub(/ +/," "); gsub(/ +\|/,"|"); gsub(/\| +/,"|") } /^[^|]+\|0x0\|/ { next; }; /^[^|]+\|na\|/ { next; }; /degrees C/ { THING=$1; TEMP=$2; OK=$4; WARN=$8; CRIT=$9; if (OK ~ /ok/) { MSG[0] = sprintf("%s %s is %dC,",MSG[0] ,THING,TEMP); perf = sprintf("%s %s=%d;%d;%d;0;100;",perf,THING,TEMP,WARN,CRIT); next; } if (CRIT !~ /na/ && TEMP>=CRIT) { MSG[2] = sprintf("%s %s is %dC (max %d) ", MSG[2], THING, TEMP, CRIT); perf = sprintf("%s %s=%d;%d;%d;0;100;",perf,THING,TEMP,WARN,CRIT); EXIT=2; next; } if (WARN !~ /na/ && TEMP>=WARN) { MSG[1] = sprintf("%s %s is %dC (max %dC, critical at %dC) ", MSG[1], THING, TEMP, CRIT); perf = sprintf("%s %s=%d;%d;%d;0;100;",perf,THING,TEMP,WARN,CRIT); if (EXIT=0) EXIT=1; next; } MSG[2] = sprintf("%s %s is %d (%s) ", MSG[2], THING, TEMP, OK); perf = sprintf("%s %s=%d;%d;%d;0;100;",perf,THING,TEMP,WARN,CRIT); if (EXIT=0) EXIT=1; } END { gsub(/, *$/,"",MSG[EXIT]); gsub(/ Temp/,"",MSG[EXIT]); gsub(/ Temp/,"",perf); print MSG[EXIT],"|",perf; exit EXIT; } '