zabbix自定义key

zabbix自定义key

1.修改客户端配置文件

#vi /opt/zabbix/etc/zabbix_agentd.conf
	Include=/opt/zabbix/etc/zabbix_agentd.conf.d/
	UnsafeUserParameters=1   

2.添加自定义key

#cd /opt/zabbix/etc/zabbix_agentd.conf.d
#vi server_sta_nginx.conf
	UserParameter=server.sta.nginx,/temp/server_sta.sh nginx
	//server.sta.nginx:填入zabbix的监控项的key
	//temp/server_sta.sh:脚本的第一个参数
	//要监控哪项服务

3.重启

#/etc/init.d/zabbix_agentd restart

4.查看是否zabbix起来

#ps -ef | grep zabbix_agent

示例:
统计一个文件中有多少行被匹配?

UserParameter=wc[*],grep -c “ $2″ $1


wc[/etc/passwd,root]
wc[/etc/services,zabbix]

$1-$9分别指参数1到参数9,$0是指文件名称。

https://www.zabbix.com/documentation/3.4/manual/appendix/macros/supported_by_location

原文地址:https://www.cnblogs.com/wspblog/p/6223187.html