。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

上面的测试只打印出主机ID。不检索主机名。
输出示例:
[{u'hostid': u'10084'}, {u'hostid': u'30000'}, {u'hostid': u'30001'}, {u'hostid': u'30002'}]

我做错什么了?:(

最佳答案

你的参数错了。它必须是数组:

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'}]

07-25 20:20