Has anyone been able to successfully retrieve all the host names of all the host severs that are in zabbix using the API? If so, can you please share? We have tried using the host.get method shown in the documentation, but all it returns is a bunch of host ID numbers. TIA
Ad Widget
Collapse
getting hostnames out of Zabbix
Collapse
X
-
In Python: https://majornetwork.net/2022/10/bas...-and-pyzabbix/
Let us know how your API call looked like, someone surely will be able to tell how to improve that.
Markku -
Hello,Has anyone been able to successfully retrieve all the host names of all the host severs that are in zabbix using the API? If so, can you please share? We have tried using the host.get method shown in the documentation, but all it returns is a bunch of host ID numbers. TIA
Here is a code snippet from a Python script of mine that exports a list of hosts based on a host group that may be useful to use
Code:# Get devices from the specified host group host_payload = { 'jsonrpc': '2.0', 'method': 'host.get', 'params': { 'output': ['hostid', 'name'], 'groupids': [host_group_id], }, 'auth': api_token, 'id': 2, } host_response = requests.post(zabbix_url, data=json.dumps(host_payload), headers=headers, verify=False) host_result = host_response.json() if 'result' in host_result: # Get the list of devices devices = [host['name'] for host in host_result['result']]Comment
Comment