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; } '
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。