步骤:

1、下载tcp链接状态监测脚本:

https://github.com/June-Wang/NagiosPlugins/blob/master/check_tcp_stat.sh

2、下载php模板

https://github.com/June-Wang/NagiosPlugins/blob/master/check_tcp_stat.php


用法:

1、将自定义命令添加到nrpe.cfg

echo 'command[check_tcp_stat]=/usr/local/nagios/libexec/check_tcp_stat.sh -w 300 -c 500 -l' >> /usr/local/nagios/etc/nrpe.cfg

参数说明:

-w -c 网络连接数阀值

-l 开启日志记录功能

注意:

1、如开启日志功能,要手动执行一次命令,程序会自动创建/var/log/tcp文件夹。

日志预览:

2014-03-03 09:27:49 Total:113 TIME_WAIT:93 ESTABLISHED:20

2014-03-03 09:30:49 Total:92 TIME_WAIT:72 ESTABLISHED:20

2014-03-03 09:33:49 Total:132 TIME_WAIT:110 ESTABLISHED:22

2014-03-03 09:36:49 Total:151 TIME_WAIT:130 FIN_WAIT1:1 ESTABLISHED:20

2014-03-03 09:39:49 Total:91 TIME_WAIT:70 ESTABLISHED:21

2014-03-03 09:42:49 Total:84 TIME_WAIT:67 ESTABLISHED:17

2014-03-03 09:45:49 Total:94 TIME_WAIT:75 FIN_WAIT2:1 ESTABLISHED:18

2014-03-03 09:48:49 Total:90 TIME_WAIT:69 ESTABLISHED:21

2014-03-03 09:51:49 Total:101 TIME_WAIT:76 ESTABLISHED:25

2014-03-03 09:55:54 Total:58 TIME_WAIT:51 ESTABLISHED:7


效果图:

nagios监控告警之tcp链接状态监测(附pnp模板)_第1张图片


注意:

1、图示里面的数值是所有状态的tcp链接数