zabbix lld使用trapper方式(zabbix_sender)
自动发现脚本文件输出格式:
{ "data": [ { "{#BIND_PERF}": "BIND INCOMING QUERY" }, { "{#BIND_PERF}": "BIND INCOMING NOTIFY" }, { "{#BIND_PERF}": "BIND INCOMING A" }, { "{#BIND_PERF}": "BIND INCOMING SOA" }, { "{#BIND_PERF}": "BIND INCOMING PTR" }, { "{#BIND_PERF}": "BIND INCOMING AAAA" }, { "{#BIND_PERF}": "BIND INCOMING IXFR" }, { "{#BIND_PERF}": "BIND INCOMING AXFR" }, { "{#BIND_PERF}": "BIND INCOMING ANY" }, { "{#BIND_PERF}": "BIND OUTGOING A" }, { "{#BIND_PERF}": "BIND OUTGOING NS" }, { "{#BIND_PERF}": "BIND OUTGOING PTR" }, { "{#BIND_PERF}": "BIND OUTGOING AAAA" }, { "{#BIND_PERF}": "BIND OUTGOING DNSKEY" } ] }
使用lld方式需要发送json格式的数据到zabbix server,这时候使用-o这种模式就会报错,这种时候我们需要使用临时文件的方式发送数据,下图是Zabbix trapper 方式discovery的配置
文件存储的格式: 主机名 监控key 值,json的值必须要和主机名、监控key放在同一行,我们这里使用配置文件来读取主机名,需要使用-来代替:
- bind.parameter {"data": [{"{#BIND_PERF}": "BIND INCOMING QUERY"}, {"{#BIND_PERF}": "BIND INCOMING NOTIFY"}, {"{#BIND_PERF}": "BIND INCOMING A"}, {"{#BIND_PERF}": "BIND INCOMING SOA"}, {"{#BIND_PERF}": "BIND INCOMING PTR"}, {"{#BIND_PERF}": "BIND INCOMING AAAA"}, {"{#BIND_PERF}": "BIND INCOMING IXFR"}, {"{#BIND_PERF}": "BIND INCOMING AXFR"}, {"{#BIND_PERF}": "BIND INCOMING ANY"}, {"{#BIND_PERF}": "BIND OUTGOING A"}, {"{#BIND_PERF}": "BIND OUTGOING NS"}, {"{#BIND_PERF}": "BIND OUTGOING PTR"}, {"{#BIND_PERF}": "BIND OUTGOING AAAA"}, {"{#BIND_PERF}": "BIND OUTGOING DNSKEY"}]}
发送脚本的命令格式:
/usr/bin/zabbix_sender -c zabbix_agentd配置文件路径 '{0}'.format(json_file) 这里的json_file就是上面的文件路径