来自:网络
#!/bin/bash
#PORT=$1
nagios培训
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='h :8236/nagios_checkpage.ashx?key=SX_MPC'
content=`curl -s $u`
#echo $content
#echo '------------------------------' nagios实施
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"; nagios安装
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; nagios配置
else
echo "${DATANAME} ERROR - Unable to determine ${DATANAME} data"; 开源监控软件
exit 3;
fi
echo "Unable to determine data.";
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流 QQ群号 :476809427
|