nagios自带的check_udp使用起来并不方便,下面的插件check_udp_nc用于代替nagios自带的check_udp.
# 'check_udp_nc' command definition
define command{
command_name check_udp_nc
command_line $USER1$/check_udp_nc.sh $HOSTADDRESS$ $ARG1$
}
-
#!/bin/sh
-
# $1 ServerIP
-
# S4 UDP Port
-
# if succeeded ,$?=0,but $?=1
-
# view $? ,use "echo $?"
-
/usr/bin/nc -uz -w1 $1 $2 |grep succeeded >/dev/null
-
if [ $? -eq 0 ]
-
then
-
echo "$1 udp-port $2 succeeded"
-
exit 0
-
else
-
echo "$1 udp-port $2 failed"
-
exit 2
-
fi
阅读(1240) | 评论(0) | 转发(0) |