diff --git a/modules/device.py b/modules/device.py index 349db0a..666fc15 100644 --- a/modules/device.py +++ b/modules/device.py @@ -545,6 +545,7 @@ class PhysicalDevice(): 'port', 'details', 'interfaceid'], selectGroups=["groupid"], + selectHostGroups=["groupid"], selectParentTemplates=["templateid"], selectInventory=list(self._inventory_map().values())) if len(host) > 1: @@ -587,7 +588,11 @@ class PhysicalDevice(): else: self.logger.debug(f"Host {self.name}: template(s) in-sync.") - for group in host["groups"]: + # Check if Zabbix version is 6 or higher. Issue #93 + group_dictname = "hostgroups" + if str(self.zabbix.version).startswith(('6', '5')): + group_dictname = "groups" + for group in host[group_dictname]: if group["groupid"] == self.group_id: self.logger.debug(f"Host {self.name}: hostgroup in-sync.") break diff --git a/requirements.txt b/requirements.txt index a48114c..33f4b90 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pynetbox -zabbix_utils +zabbix-utils==2.0.1