I'm using Python to query a Zabbix server in an attempt to get a list of hostids and hostnames. I'm testing with the following:
zapi = ZabbixAPI(server=server, log_level=debuglevel)
zapi.login(username, password)
hosts = zapi.host.get({"params":{"output":"hostid", "name"}})
print hosts
The above test only prints out the hostids. The host names are not retrieved.
example of output:
[{u'hostid': u'10084'}, {u'hostid': u'30000'}, {u'hostid': u'30001'}, {u'hostid': u'30002'}]
What I am doing wrong? :(
Your parameters are wrong. It must be array:
zapi = ZabbixAPI(server=server, log_level=debuglevel)
zapi.login(username, password)
hosts = zapi.host.get(output=["hostid", "name"])
print hosts
[{u'hostid': u'10084', u'name': u'Zabbix server'}]