Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Level discover #87

Open
mbribeiro opened this issue Aug 15, 2018 · 1 comment
Open

Low Level discover #87

mbribeiro opened this issue Aug 15, 2018 · 1 comment

Comments

@mbribeiro
Copy link

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.

@dangelovich
Copy link

dangelovich commented Aug 28, 2018

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants