Zabbix_server 3.0.5
Zabbix_agentd 3.0.5
Zabbix_agentd端(被监控端)
Zabbix_agentd配置:
vim /etc/zabbix/scripts/tcpstatus.sh
#!/bin/bash#tcpstatus monitorstat() {netstat -an | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'}case $1 inTIME_WAIT)stat |grep 'TIME_WAIT' |awk '{print $2}';;CLOSE_WAIT)stat | grep 'CLOSE_WAIT' |awk '{print $2}';;CLOSED)stat | grep 'CLOSED' |awk '{print $2}';;CLOSING)stat | grep 'CLOSING' |awk '{print $2}';;FIN_WAIT1)stat | grep 'FIN_WAIT1' |awk '{print $2}';;FIN_WAIT2)stat | grep 'FIN_WAIT2' |awk '{print $2}';;ESTABLISHED)stat | grep 'ESTABLISHED' |awk '{print $2}';;SYN_RECV)stat |grep 'SYN_RECV' |awk '{print $2}';;SYN_SENT)stat |grep 'SYN_SENT' |awk '{print $2}';;LAST_ACK)stat |grep 'LAST_ACK' |awk '{print $2}';;LISTEN)stat |grep 'LISTEN' |awk '{print $2}';;*)echo "Usage: TIME_WAIT CLOSE_WAIT FIN_WAIT1 ESTABLISHED SYN_RECV LAST_ACK LISTEN";;esac
chmod +x nginx_status.sh
vim /etc/zabbix/zabbix_agentd.d/userparameter_tcpstatus.conf
UserParameter=tcp.time_wait,/etc/zabbix/scripts/tcpstatus.sh TIME_WAITUserParameter=tcp.close_wait,/etc/zabbix/scripts/tcpstatus.sh CLOSE_WAITUserParameter=tcp.fin_wait1,/etc/zabbix/scripts/tcpstatus.sh FIN_WAIT1UserParameter=tcp.established,/etc/zabbix/scripts/tcpstatus.sh ESTABLISHEDUserParameter=tcp.syn_recv,/etc/zabbix/scripts/tcpstatus.sh SYN_RECVUserParameter=tcp.last_ack,/etc/zabbix/scripts/tcpstatus.sh LAST_ACKUserParameter=tcp.listen,/etc/zabbix/scripts/tcpstatus.sh LISTENUserParameter=tcp.closed,/etc/zabbix/scripts/tcpstatus.sh CLOSEDUserParameter=tcp.closing,/etc/zabbix/scripts/tcpstatus.sh CLOSINGUserParameter=tcp.syn_sent,/etc/zabbix/scripts/tcpstatus.sh SYN_SENTUserParameter=tcp.fin_wait2,/etc/zabbix/scripts/tcpstatus.sh FIN_WAIT2
重启Zabbix_agentd
/etc/init.d/zabbix-agent restart
Zabbix_server端(监控端):
Zabbix_server端获取监控数据:
/usr/local/zabbix/bin/zabbix_get -s Zabbix_agentd端IP -p 10050 -k tcp.time_wait
245
创建监控模板Templates
创建后续导入模版Template TCP Status.xml
3.0 2017-05-03T09:44:29Z Templates Template TCP Status Template TCP Status Templates Tcpstatus tcp.closed 0 0 tcp.closed 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.close_wait 0 0 tcp.close_wait 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.closing 0 0 tcp.closing 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.established 0 0 tcp.established 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.fin_wait1 0 0 tcp.fin_wait1 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.fin_wait2 0 0 tcp.fin_wait2 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.last_ack 0 0 tcp.last_ack 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.listen 0 0 tcp.listen 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.syn_recv 0 0 tcp.syn_recv 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.syn_sent 0 0 tcp.syn_sent 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus tcp.time_wait 0 0 tcp.time_wait 30 90 365 0 3 0 0 0 0 1 0 0 0 Tcpstatus Tcpstatus 900 200 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 611F27 0 2 0 Template TCP Status tcp.closed 1 0 F230E0 0 2 0 Template TCP Status tcp.close_wait 2 0 5CCD18 0 2 0 Template TCP Status tcp.closing 3 0 BB2A02 0 2 0 Template TCP Status tcp.established 4 0 5A2B57 0 2 0 Template TCP Status tcp.fin_wait1 5 0 89ABF8 0 2 0 Template TCP Status tcp.fin_wait2 6 0 7EC25C 0 2 0 Template TCP Status tcp.last_ack 7 0 274482 0 2 0 Template TCP Status tcp.listen 8 0 2B5429 0 2 0 Template TCP Status tcp.syn_recv 9 0 8048B4 0 2 0 Template TCP Status tcp.syn_sent 10 0 FD5434 0 2 0 Template TCP Status tcp.time_wait
创建应用项Applications
创建监控项
创建监控图形
关联对应的主机,根据需求设置修改相关的配置(Triggers Macros)