Recently, because the server is constantly adding new business, the server needs to adjust the maximum number of connections, so the use of Nagios to monitor the corresponding number of connections, the script is also using Nagios to send the corresponding state to implement monitoring, implementation is also very simple
#/bin/bash#used to monitor the number of sockets connections in Nagios#writer jim#histor#2017.6.15state_ok=0state_warning =1state_criticalll=2state_unknown=3declare-i socket_num=$ (ss-an|wc-l) declare-i max_num=65535if [$socket _num-le $ Max_num]; Then echo "The number of sockets connections is $socket _num. Ok "Exit $STATE _okelse echo" Error!!! The number of socket connections is too much.the number is $socket _num "Exit $STATE _criticallfi
This article from "Technical essay" blog, declined reprint!
Script for monitoring server connections in Nagios