学向勤中得,萤窗万卷书。这篇文章主要讲述zabbix-监控tcp连接相关的知识,希望能为你提供帮助。
【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
测试
修改配置文件【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]"
?
提示permission denied
修改/tmp/tcp_conn.txt权限
?
监控模板
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_CONNStatus< /template>
< name> Template Linux TCP_CONNStatus< /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> 0推荐阅读
- 的表达能力相结合,为语义引导
- 可能认为你是会使用键盘的最聪明的开发者
- 度学习的算法,能够从航拍图像中检测
- 者和开发者沟通吗? 你的团队
- ceph 工具说明 #yyds干货盘点#
- 如何解决WordPress网站上的重叠问题
- 如何在WordPress子主题中加入第二个样式表()
- 如何在wordpress中编辑bootstrap.min.css
- 如何在WP的父页面上显示子页面的自定义字段()