最近因为服务器不断有增加新的业务,需要对服务器的最大连接数进行调整评估,所以就利用Nagios去监控相应的连接数,脚本也是利用Nagios发送相应的转态来实现监控,实现也很简单
#/bin/bash #Used to monitor the number of socket connections in Nagios #writer jim #histor #2017.6.15 STATE_OK=0 STATE_WARNING=1 STATE_CRITICALLL=2 STATE_UNKNOWN=3 declare -i socket_num=$(ss -an|wc -l) declare -i max_num=65535 if [ $socket_num -le $max_num ] ; then echo "The number of socket connections is $socket_num.OK" exit $STATE_OK else echo "error!!!The number of socket connections is too much.the number is $socket_num" exit $STATE_CRITICALL fi
时间: 2024-10-29 04:13:22