标签:
UserParameter=net.tcp.listen.grep[*],grep -q $$(printf ‘%04X.00000000:0000.0A‘ $1) /proc/net/tcp && echo 1 || echo 0
例如我的选在就是在/etc/zabbix/zabbix-agentd.conf.d目录下,创建了一个文件net_tcp_listen.conf,将上述key的声明写到文件里,因为我的zabbix_agentd.conf中已经做了配置文件目录包含的声明:
thatsit:~ # grep ^Include /etc/zabbix/zabbix-agentd.conf Include=/etc/zabbix/zabbix-agentd.conf.d/ thatsit:~ # thatsit:~ # cat /etc/zabbix/zabbix-agentd.conf.d/net_tcp_listen.conf UserParameter=net.tcp.listen.grep[*],grep -q $$(printf ‘%04X.00000000:0000.0A‘ $1) /proc/net/tcp && echo 1 || echo 0 thatsit:~ #
shipeng:~ # /etc/init.d/zabbix-agentd restart Shutting down zabbix agentd done Starting zabbix agentd done shipeng:~ #
thatsit:~ # zabbix_get -s 192.168.3.154 -k "net.tcp.listen.grep[22]" 1 thatsit:~ # zabbix_get -s 192.168.3.154 -k "net.tcp.listen.grep[23]" 0 thatsit:~ #
监控项的key即是:net.tcp.listen.grep[要监控的端口号]
至此配置已经完成,如果有问题,可以按照以下思路进行排查,一般的问题在日志中都可以找到端倪。
thatsit:~ # grep ^Unsafe /etc/zabbix/zabbix-agentd.conf UnsafeUserParameters=1 thatsit:~ #
标签:
原文地址:http://www.cnblogs.com/thatsit/p/5667321.html