mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-16 04:02:56 -06:00
Fixed #6
This commit is contained in:
parent
1ce73b3457
commit
036a0c06d1
@ -114,22 +114,22 @@ def main(arguments):
|
|||||||
logger.info(f"Skipping host {device.name} since its "
|
logger.info(f"Skipping host {device.name} since its "
|
||||||
f"not in the active state.")
|
f"not in the active state.")
|
||||||
continue
|
continue
|
||||||
|
# Add hostgroup is flag is true
|
||||||
|
# and Hostgroup is not present in Zabbix
|
||||||
|
if(arguments.hostgroups):
|
||||||
|
for group in zabbix_groups:
|
||||||
|
# If hostgroup is already present in Zabbix
|
||||||
|
if(group["name"] == device.hostgroup):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
# Create new hostgroup
|
||||||
|
hostgroup = device.createZabbixHostgroup()
|
||||||
|
zabbix_groups.append(hostgroup)
|
||||||
|
# Device is already present in Zabbix
|
||||||
if(device.zabbix_id):
|
if(device.zabbix_id):
|
||||||
# Device is already present in Zabbix
|
|
||||||
device.ConsistencyCheck(zabbix_groups, zabbix_templates)
|
device.ConsistencyCheck(zabbix_groups, zabbix_templates)
|
||||||
|
# Add device to Zabbix
|
||||||
else:
|
else:
|
||||||
# Add hostgroup is flag is true
|
|
||||||
# and Hostgroup is not present in Zabbix
|
|
||||||
if(arguments.hostgroups):
|
|
||||||
for group in zabbix_groups:
|
|
||||||
if(group["name"] == device.hostgroup):
|
|
||||||
# If hostgroup is already present in Zabbix
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# Create new hostgroup
|
|
||||||
hostgroup = device.createZabbixHostgroup()
|
|
||||||
zabbix_groups.append(hostgroup)
|
|
||||||
# Add device to Zabbix
|
|
||||||
device.createInZabbix(zabbix_groups, zabbix_templates)
|
device.createInZabbix(zabbix_groups, zabbix_templates)
|
||||||
except SyncError:
|
except SyncError:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user