-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcheckInventoryName.py
More file actions
executable file
·28 lines (19 loc) · 960 Bytes
/
checkInventoryName.py
File metadata and controls
executable file
·28 lines (19 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Check all hosts and return host name <-> inventory name matching
"""
from zabbix.api import ZabbixAPI
zabbixServer = 'http://yourserver/zabbix/'
zabbixUser = 'someuser'
zabbixPass = 'somepass'
zapi = ZabbixAPI(url=zabbixServer, user=zabbixUser, password=zabbixPass)
hosts = zapi.host.get(selectInventory='extend', output=['hostids', 'host'])
for host in hosts:
if (host['inventory']['name']):
if (host['inventory']['name'] is not host['host']):
print "Mismatch on id {}: Host Name: {} - SNMP Inventory Name: {} ".format(host['hostid'], host['host'], host['inventory']['name'])
else:
print "Matching inventory name on id {}: Host Name: {}".format(host['hostid'], host['host'], host['inventory']['name'])
else:
print "Missing inventory name on id {}: Host Name: {}".format(host['hostid'], host['host'], host['inventory']['name'])