在zabbix_agentd上准备监控脚本
#监控指标有 TIME_WAIT CLOSE_WAIT FIN_WAIT1 ESTABLISHED SYN_RECV LAST_ACK LISTEN [root@zabbix-client ~]# cat /usr/local/zabbix/etc/tcp_connections.sh #!/bin.bash netstat -an | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}‘ | grep $1 |awk ‘{print $$2}‘
修改zabbix_agentd配置文件
[root@zabbix-client ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf UnsafeUserParameters=1 #确保值为1 UserParameter=TIME_WAIT,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh TIME_WAIT UserParameter=CLOSE_WAIT,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh CLOSE_WAIT UserParameter=FIN_WAIT1,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh FIN_WAIT1 UserParameter=ESTABLISHED,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh ESTABLISHED UserParameter=SYN_RECV,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh SYN_RECV UserParameter=LAST_ACK,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh LAST_ACK UserParameter=LISTEN,/bin/bash /usr/local/zabbix/etc/tcp_connections.sh LISTEN #重启zabbix_agentd服务 [root@zabbix-client ~]# service zabbix_agentd restart #在zabbix-server上测试监控是否正常 [root@zabbix-server ~]# zabbix_get -s 192.168.3.42 -k ESTABLISHED 2
本文出自 “ly36843运维” 博客,请务必保留此出处http://ly36843.blog.51cto.com/3120113/1671399
原文地址:http://ly36843.blog.51cto.com/3120113/1671399