十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
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; } '