1
0
mirror of https://github.com/ranl/monitor-utils.git synced 2024-11-05 23:53:43 +01:00
monitor-utils/zabbix/scripts/list_ips.py

22 lines
562 B
Python
Raw Normal View History

2013-12-02 14:24:24 +01:00
#!/usr/bin/env python
'''
Uses the zabbix python api to retrieve a list the all servers names & ips
Need to configure the server, username & passwords settings
'''
from zabbix_api import ZabbixAPI
server="https://url.of.zabbix.site"
username="user of read on all hosts"
password="pass"
zapi = ZabbixAPI(server=server, path="")
zapi.login(username, password)
hosts=zapi.host.get({"selectInterfaces": "extend", "output": "extend"})
for host in hosts:
for int in host['interfaces']:
print "{}\t{}".format(host['host'],host['interfaces'][int]['ip'])
break