zabbix-监控tcp连接

Posted 小怪獣55

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix-监控tcp连接相关的知识,希望对你有一定的参考价值。

主动模式测试:

主动模式参考:​​https://blog.51cto.com/u_14814545/4869452​

获取监控值脚本【192.168.47.105】

root@ubuntu:/etc/zabbix/zabbix_agentd.d# pwd
/etc/zabbix/zabbix_agentd.d

vim tcp_conn.sh
-------------------------------------------------------------------------------------
tcp_conn_status()
TCP_STAT=$1
ss -ant | awk NR>1 ++s[$1] END for(k in s) print k,s[k] > /tmp/tcp_conn.txt
TCP_NUM=$(grep "$TCP_STAT" /tmp/tcp_conn.txt | cut -d -f2)
if [ -z $TCP_NUM ];then
TCP_NUM=0
fi
echo $TCP_NUM

main()
case $1 in
tcp_status)
tcp_conn_status $2;
;;
esac

main $1 $2
-------------------------------------------------------------------------------------

chmod a+x tcp_conn.sh.sh

测试

zabbix-监控tcp连接_zabbix监控tcp连接

修改配置文件【192.168.47.105】

vim /etc/zabbix/zabbix_agentd.conf
------------------------------------------------------------------------------
UserParameter=linux_status[*],/etc/zabbix/zabbix_agentd.d/tcp_conn.sh $1 $2
------------------------------------------------------------------------------

systemctl restart zabbix-agent

测试【192.168.47.104】

/apps/zabbix_agent/bin/zabbix_get -s 192.168.47.105 -p 10050 -k "linux_status[tcp_status,LISTEN]"

zabbix-监控tcp连接_zabbix监控tcp连接_02

提示permission denied

修改/tmp/tcp_conn.txt权限

zabbix-监控tcp连接_zabbix监控tcp连接_03

监控模板

Template Linux TCP_CONN Status.xml.xml

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.0</version>
<date>2018-11-23T09:46:44Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Template Linux TCP_CONN Status</template>
<name>Template Linux TCP_CONN Status</name>
<description/>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>TCP Stauts</name>
</application>
</applications>
<items>
<item>
<name>TCP Status CLOSE_WAIT</name>
<type>7</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>linux_status[tcp_status,CLOSE-WAIT]</key>
<delay>300</delay>
<history>30</history>
<trends>90</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>TCP Stauts</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>TCP Status CLOSED</name>
<type>7</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>linux_status[tcp_status,CLOSED]</key>
<delay>300</delay>
<history>30</history>
<trends>90</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>TCP Stauts</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>TCP Status CLOSING</name>
<type>7</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>linux_status[tcp_status,CLOSING]</key>
<delay>300</delay>
<history>30</history>
<trends>90</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>TCP Stauts</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>TCP Status ESTABLISHED</name>
<type>7</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>linux_status[tcp_status,ESTAB]</key>
<delay>30</delay>
<history>30</history>
<trends>90</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0zabbix TCP 连接数监控

zabbix监控硬盘指标,tcp连接状态

ZABBIX之TCP连接数监控

zabbix如何监控tcp连接数

ZABBIX监控TCP连接状态

Zabbix 监控 tcp 连接状态的第二版(python+zabbix_sender)