zabbix 监控TCP状态连接数
1、zabbix客户端,监控TCP状态脚本,并保存到的定路径。(/usr/local/zabbix-agent/shells)
# cat zabbix_linux_plugin.sh #!/bin/bash ############################################################ # $Name: zabbix_linux_plugins.sh # $Version: v1.0 # $Function: zabbix plugins # $Create Date: 2014-08-10 # $Description: Monitor Linux Service Status ############################################################ tcp_status_fun(){TCP_STAT=$1ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}' > /tmp/netstat.tmpTCP_STAT_VALUE=$(grep "$TCP_STAT" /tmp/netstat.tmp | cut -d ' ' -f2)if [ -z $TCP_STAT_VALUE ];thenTCP_STAT_VALUE=0fiecho $TCP_STAT_VALUE }main(){case $1 intcp_status)tcp_status_fun $2;;;*)echo $"Usage: $0 {tcp_status key}"esac }main $1 $2 $3
2、在客户端中修改zabbix_agentd.conf配置文件(/usr/local/zabbix-agent/etc/zabbix_agentd.conf)
### Option: Include # You may include individual files or all files in a directory in the configuration file. # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. # # Mandatory: no # Default: # Include=# Include=/usr/local/etc/zabbix_agentd.userparams.conf # Include=/usr/local/etc/zabbix_agentd.conf.d/ Include=/usr/local/zabbix-agent/etc/zabbix_agentd.conf.d/*.conf
3、在客户端中配置自定义KEY配置文件(/usr/local/zabbix-agent/etc/zabbix_agentd.conf.d/zabbix-linux-plugin.conf)
# cat zabbix-linux-plugin.conf UserParameter=linux_status[*],/usr/local/zabbix-agent/shells/zabbix_linux_plugin.sh "$1" "$2" "$3"
4、以上配置完成,重启zabbix agent服务
# /etc/init.d/zabbix_agentd restart
5、tcp连接状态模板,这是配置好的模板,包括了TCP连接的11种状态,如果模板就需要一个一个的创建了。
# cat TCP_export_templates.3.0.xml <?xml version="1.0" encoding="UTF-8"?> <zabbix_export><version>3.0</version><date>2016-06-18T06:34:48Z</date><groups><group><name>Templates</name></group></groups><templates><template><template>Template Linux TCP Status</template><name>Template Linux TCP 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>0</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>0</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>0</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> # ESTABLISHED状态模板,我们通过zabbix_get命令获取这个KEY,看是否可以正常获取 <name>TCP Status ESTABLISHED</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,ESTAB]</key> # 这就是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 FIN_WAIT1</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,FIN-WAIT-1]</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 FIN_WAIT2</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,FIN-WAIT-2]</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 LAST_ACK</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,LAST-ACK]</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 LISTEN</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,LISTEN]</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 SYN_RCVD</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,SYN-RECV]</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 SYN_SENT</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,SYN-SENT]</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 TIME_WAIT</name><type>0</type><snmp_community/><multiplier>0</multiplier><snmp_oid/><key>linux_status[tcp_status,TIME-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></items><discovery_rules/><macros/><templates/><screens/></template></templates><graphs><graph><name>TCP Status Statistics</name><width>900</width><height>200</height><yaxismin>0.0000</yaxismin><yaxismax>100.0000</yaxismax><show_work_period>1</show_work_period><show_triggers>1</show_triggers><type>0</type><show_legend>1</show_legend><show_3d>0</show_3d><percent_left>0.0000</percent_left><percent_right>0.0000</percent_right><ymin_type_1>0</ymin_type_1><ymax_type_1>0</ymax_type_1><ymin_item_1>0</ymin_item_1><ymax_item_1>0</ymax_item_1><graph_items><graph_item><sortorder>0</sortorder><drawtype>0</drawtype><color>C80000</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,CLOSED]</key></item></graph_item><graph_item><sortorder>1</sortorder><drawtype>0</drawtype><color>00C800</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,CLOSE-WAIT]</key></item></graph_item><graph_item><sortorder>2</sortorder><drawtype>0</drawtype><color>0000C8</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,CLOSING]</key></item></graph_item><graph_item><sortorder>3</sortorder><drawtype>0</drawtype><color>C800C8</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,ESTAB]</key></item></graph_item><graph_item><sortorder>4</sortorder><drawtype>0</drawtype><color>00C8C8</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,FIN-WAIT-1]</key></item></graph_item><graph_item><sortorder>5</sortorder><drawtype>0</drawtype><color>C8C800</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,FIN-WAIT-2]</key></item></graph_item><graph_item><sortorder>6</sortorder><drawtype>0</drawtype><color>C8C8C8</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,LAST-ACK]</key></item></graph_item><graph_item><sortorder>7</sortorder><drawtype>0</drawtype><color>960000</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,LISTEN]</key></item></graph_item><graph_item><sortorder>8</sortorder><drawtype>0</drawtype><color>009600</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,SYN-RECV]</key></item></graph_item><graph_item><sortorder>9</sortorder><drawtype>0</drawtype><color>000096</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,SYN-SENT]</key></item></graph_item><graph_item><sortorder>10</sortorder><drawtype>0</drawtype><color>960096</color><yaxisside>0</yaxisside><calc_fnc>2</calc_fnc><type>0</type><item><host>Template Linux TCP Status</host><key>linux_status[tcp_status,TIME-WAIT]</key></item></graph_item></graph_items></graph></graphs> </zabbix_export>
6、zabbix server 端通过zabbix_get命令进行测试,验证是否可以正常获取TCP状态值
[root@linux-node1 ~]# zabbix_get -s 172.16.10.152 -k linux_status[tcp_status,ESTAB] 2 [root@linux-node1 ~]# zabbix_get -s 172.16.10.152 -k linux_status[tcp_status,LISTEN] 6
通过测试,我们可以看到,已经可以正确获取到值了,那么我们接下来,就可以在web页面将模板进行导入了。
7、zabbix web 监控页面导入tcp连接状态模板
模板(TCP_export_templates.3.0.xml)导入成功后,将模板链接到一台就机就可以了。
最后我们来看下TCP状态有没有监控上吧。
好了,数据也有了,图形展示也有了,监控TCP状态就介绍到这里了。
转载于:https://www.cnblogs.com/miclesvic/p/6196670.html
zabbix 监控TCP状态连接数相关推荐
- linux tcp 监控,Zabbix 监控tcp连接的状态
Tcp的连接状态对于我们web服务器来说是至关重要的,尤其是并发量ESTAB:或者是syn_recv值,假如这个值比较大的话我们可以认为是不是受到了攻击,或是是time_wait值比较高的话,我们要考 ...
- zabbix监控TCP连接状态
一 .zabbix监控TCP连接状态 1.取到TCP连接状态的值 [root@web01 ~]# netstat -antp | awk 'NR>2{print $6}' | grep &quo ...
- Zabbix监控Redis状态
一.Zabbix监控Redis状态 监控redis通过info信息来监控redis的状态 自动发现脚本编写 cat /etc/zabbix/scripts/redis_parameter #自动发现r ...
- zabbix监控nginx状态,显示状态active,accepts,handled,requests
zabbix监控nginx状态,显示状态active,accepts,handled,requests 一. 首先,zabbix server部署完成,可用. 接上篇zabbix部署文章,我这里zab ...
- 配置zabbix监控nginx状态,监控华为路由器
配置zabbix监控nginx状态,监控华为路由器 1.安装并开启nginx [root@localhost ~]# yum install nginx -y [root@localhost ~]# ...
- Zabbix 监控MySQL最大连接数
Zabbix-agent端 mkdir /etc/zabbix/scripts #新建script目录,方便脚本管理 cd /etc/zabbix/scripts touch 3306PortNum. ...
- Zabbix 监控TCP的SYN,establised
1.在 agent 端建立脚本,并赋予 zabbix 执行权限 #!/bin/bash # Script to fetch Netstat statuses for tribily monitorin ...
- zabbix监控nginx状态界面
文章目录 开启状态界面 监控nginx状态界面 开启状态界面 实例: 开启status: location /status {stub_status {on | off};allow 172.16.0 ...
- zabbix监控TCP连接数
模板可以将多个监控项 触发器 图形都配置在模板中,方便多个监控的主机进行重复调用,提升了很多的工作效率 模板的简单配置 1.配置-----模板---------创建模板 配置合适的模板名称再点击添加 ...
最新文章
- 海量数据处理的思路和方法
- 清理和删除svn信息
- Linux下远程桌面连接windows
- go语言的书籍的淘宝调查
- shapefile导入oracle,shp2sdo.exe用法:shpfile导入OracleSpatial
- XSRF(XSS+CSRF)
- 灰色按钮激活程序的原理 (学习)
- 网格交易法:数学+传统智慧战胜华尔街
- 锁定计算机还能远程控制,我的电脑可能被远程控制
- 使用jwPlayer播放视频中的某一段
- 《多收了三五斗》大学毕业版 (转)
- JAVA复制数组的三种方法
- nepctf2021
- SQL消费表中查找所有用户最后一条消费记录
- 水浒传108将都是怎么死的
- Qt QImage类详解(QImage类型转换、QImage类函数及QImage像素操作)
- mac 隐藏文件(隐藏文件夹)怎么取消隐藏,显示文件(夹)
- 专业的知识图谱应用门槛正在被不断降低
- 打造中国版ChatGPT,国内有哪些学术力量能抢滩?
- 主流防护元器件ESD管静电防护优势及选型
热门文章
- python字典和集合对象可以进行索引操作_python字典和列表的高级应用
- java netty modbus协议接收iot数据
- js实现kmp算法_字符串匹配算法KMP算法
- python语言的缺点-python优缺点分析及python种类
- 遇到一个日志文件变化带来的文件句柄问题
- 我的内核学习笔记4:sysfs学习
- 【Clickhouse】Clickhouse MergeTree家族引擎
- 【jmx】JMX最佳实践与详解
- 【Kafka】Kafka Record for partition topic at offset xx is invalid, cause: Record corrupt
- 【IDEA】IDEA报错 illegal character U+00A0异常解决