当前位置: 首页 > OpenSource > 正文

nagios check_udp 就是一残废

nagios中check_udp是链接到的check_tcp
lrwxrwxrwx 1 root root 9 Sep 23 22:01 check_udp -> check_tcp

两个例子:
./check_udp -H 2hei.net -p 161 -s “” -e “” -w 2 -c 5
No data received from host

./check_udp -H 2hei.net -p 123 -s “” -e “” -w 2 -c 5
CRITICAL – Socket timeout after 10 seconds

/usr/lib64/nagios/plugins/check_udp -h
check_udp: No arguments found
Usage:
check_udp -H host -p port [-w ] [-c ] [-s ]
[-e ] [-q ][-m ] [-d ]
[-t ] [-r ] [-M ] [-v] [-4|-6] [-j]
[-D [,]] [-S ] [-E]

需要输入[-s ] [-e ]实际上很多ndp的端口就没有返回内容,太扯淡了。
看来还得自己动手丰衣足食。

根据netstat值,简单写了一个,先凑合着用:

#!/bin/bash
# check_udpport
# by 2hei.net 2013.11.03

PORT=$1
if [ -z ${PORT} ];then
echo “Port is null”
exit 1
fi

LISTEN_NUM=`/bin/netstat -lnup | grep ${PORT} | grep -v grep | wc -l`
if [ ${LISTEN_NUM} -ge 1 ];then
echo “OK. UDP port ${PORT} is running.”
exit 0
else
echo “CRITICAL. UDP port ${PORT} listen number is ${LISTEN_NUM},please check.”
fi

/usr/lib64/nagios/plugins/check_udpport 5002
OK. UDP port 5002 is running.

/usr/lib64/nagios/plugins/check_udpport 161
CRITICAL. UDP port 161 listen number is 2,please check.

实际上可以自定义修改,udp端口监听的数量可能不止一个哦。

本文固定链接: https://www.2hei.net/2013/11/03/nagios-check_udp-is-pool/ | 2hei.net

该日志由 u2 于2013年11月03日发表在 OpenSource 分类下,
原创文章转载请注明: nagios check_udp 就是一残废 | 2hei.net
关键字:

报歉!评论已关闭.