标签:
#!/bin/bash #PORT=$1 u=$1 w=$2 c=$3 BC=/usr/bin/bc GREP=/bin/grep AWK=/bin/awk HEAD=/usr/bin/head TAIL=/usr/bin/tail #u=‘http://219.148.23.137:8236/nagios_checkpage.ashx?key=SX_MPC‘ content=`curl -s $u` #echo $content #echo ‘------------------------------‘ eval $(awk -v info="$content" ‘BEGIN{split(info,tA,";");printf("n=%s;t=%s;",tA[1],tA[2]);}‘) #echo $n $t #echo ‘------------------------------‘ eval $(awk -v info="$t" ‘BEGIN{split(info,tA,":");printf("WAIT=%s",tA[2]);}‘) #echo "Wait=" $WAIT eval $(awk -v info="$n" ‘BEGIN{split(info,tA,":");printf("DATANAME=%s",tA[1]);}‘) #echo "DATANAME=" $DATANAME #echo ‘------------------------------‘ if [ `echo "$WAIT >= $c" |bc` == 1 ] ;then echo "${DATANAME} CRITICAL - ${DATANAME} Wait=${WAIT} |Wait=${WAIT};${w};${c} all=1;1;1"; exit 2; elif [ `echo "$WAIT >= $w" |bc` == 1 ] ;then echo "${DATANAME} WARNING - ${DATANAME} Wait = ${WAIT} |Wait=${WAIT};${w};${c} all=1;1;1"; exit 1; elif [ `echo "$WAIT < $w" |bc` == 1 ] ;then echo "${DATANAME} OK - ${DATANAME} Wait = ${WAIT} |Wait=${WAIT};${w};${c} all=1;1;1"; exit 0; else echo "${DATANAME} ERROR - Unable to determine ${DATANAME} data"; exit 3; fi echo "Unable to determine data.";
标签:
原文地址:http://my.oschina.net/janl/blog/499654