Custom monitoring Items (monitor site 80 connections)
Requirements: Monitoring a web of 80 port connections, and out of the picture;
The first step: client creation Script:
The client-side definition script, and edit the zabbix-agent configuration file implementation run the definition of the script;
Client settings
vim /usr/local/sbin/estab.sh //创建脚本
#!/bin/bash##获取80端口并发连接数netstat -ant |grep ‘:80‘ |grep -c ESTABLISHED##netstat -ant是查看当前连接数,grep ‘:80‘是过滤出80端口,grep -c ESTABLISHED是统计ESTABLISHED有多少列
chmod 755 /usr/local/sbin/estab.sh //给脚本755权限,拥有者可读写执行,其他可读和执行;
vim /etc/zabbix/zabbix_agentd.conf //编辑配置文件,增加下面代码
UnsafeUserParameters=1 //表示使用自定义脚本UserParameter=my.estab.count[*],/usr/local/sbin/estab.sh //自定义键值名my.estab.count,后面的[*]里面写脚本的参数,如果没有参数则可以省略,脚本为/usr/local/sbin/estab.sh
systemctl restart zabbix-agent //重启zabbix-agent服务
Step two: Server-side test script:
Service-side verification, the execution of the command is normal;
zabbix_get -s 192.168.188.3 -p 10050 -k ‘my.estab.count‘ //使用zabbix_get工具 连接到192.168.188.3:10050 执行键值my.estab.count
Step three: Web Setup Step 1: Create a monitoring entry
Configuration--Host--Select the corresponding host ' shu001 '--select ' Monitor '--' Create monitoring item '
Step 2: Add graphics to the monitoring item
Configuration--host--' shu001 ' host--graphics--Create graphics--give the graph a cool name--Add a monitoring item to the graph "Monitor 80 concurrency" (that is, the monitor item you just created)--add
zabbix-Custom monitoring items (monitoring site 80 connections)