py-zabbix
py-zabbix copied to clipboard
Low Level discover
Is this possible to use py-zabbix with Low Level Discover ? I did not see any example of dynamic item creation. I was able to update status of an already created item using zabbix_sender.
I'm doing exactly this, by pushing through a string in the correct format to a discovery item, which is a Zabbix Trapper.
discovery = {}
data = []
for item in list(set(items)):
data.append({"{#APPMETRIC}":item, "{#APPNAME}":item.split('.')[0].upper()})
discovery['data'] = data
discoverystring = json.dumps(discovery)
logging.debug("Discovery String: %s", discoverystring)
zabbixkey = "v20metrics.discovery[%s]" % (discoverytype)
logging.debug("Zabbix Key: %s", zabbixkey)
packet = [ZabbixMetric("myhostname", zabbixkey, discoverystring)]
result = ZabbixSender(use_config='/etc/zabbix/zabbix_agentd.conf').send(packet)
logging.debug(pprint.pformat(result))
Only problem I'm finding is that the hostname "-" isn't accepted like it would be with the zabbix_sender binary (where it would just sub in the Hostname= from the agent config). Instead, I have to pass the matching hostname. Not a big deal...