Merge pull request #135 from retigra/issue-131

🐛 Fixes for issue #131
This commit is contained in:
Raymond Kuiper 2025-06-24 17:52:13 +02:00 committed by GitHub
commit 1cf24fbcb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 9 deletions

View File

@ -229,6 +229,7 @@ class PhysicalDevice:
self.inventory = field_mapper( self.inventory = field_mapper(
self.name, self._inventory_map(), nbdevice, self.logger self.name, self._inventory_map(), nbdevice, self.logger
) )
self.logger.debug(f"Host {self.name}: Resolved inventory: {self.inventory}")
return True return True
def isCluster(self): def isCluster(self):
@ -428,16 +429,16 @@ class PhysicalDevice:
tags = ZabbixTags( tags = ZabbixTags(
self.nb, self.nb,
self._tag_map(), self._tag_map(),
config['tag_sync'], tag_sync=config['tag_sync'],
config['tag_lower'], tag_lower=config['tag_lower'],
tag_name=config['tag_name'], tag_name=config['tag_name'],
tag_value=config['tag_value'], tag_value=config['tag_value'],
logger=self.logger, logger=self.logger,
host=self.name, host=self.name,
) )
if tags.sync is False: if config['tag_sync'] is False:
self.tags = [] self.tags = []
return False
self.tags = tags.generate() self.tags = tags.generate()
return True return True

View File

@ -15,7 +15,7 @@ class ZabbixTags:
self, self,
nb, nb,
tag_map, tag_map,
tag_sync, tag_sync=False,
tag_lower=True, tag_lower=True,
tag_name=None, tag_name=None,
tag_value=None, tag_value=None,
@ -130,4 +130,6 @@ class ZabbixTags:
if t: if t:
tags.append(t) tags.append(t)
return remove_duplicates(tags, sortkey="tag") tags = remove_duplicates(tags, sortkey="tag")
self.logger.debug(f"Host {self.name}: Resolved tags: {tags}")
return tags

View File

@ -159,7 +159,7 @@ def sanatize_log_output(data):
""" """
Used for the update function to Zabbix which Used for the update function to Zabbix which
shows the data that its using to update the host. shows the data that its using to update the host.
Removes and sensitive data from the input. Removes any sensitive data from the input.
""" """
if not isinstance(data, dict): if not isinstance(data, dict):
return data return data
@ -168,7 +168,8 @@ def sanatize_log_output(data):
if "macros" in data: if "macros" in data:
for macro in sanitized_data["macros"]: for macro in sanitized_data["macros"]:
# Check if macro is secret type # Check if macro is secret type
if not macro["type"] == str(1): if not (macro["type"] == str(1) or
macro["type"] == 1):
continue continue
macro["value"] = "********" macro["value"] = "********"
# Check for interface data # Check for interface data

View File

@ -6,7 +6,7 @@ All of the Zabbix Usermacro related configuration
from logging import getLogger from logging import getLogger
from re import match from re import match
from modules.tools import field_mapper from modules.tools import field_mapper, sanatize_log_output
class ZabbixUsermacros: class ZabbixUsermacros:
@ -98,6 +98,7 @@ class ZabbixUsermacros:
Generate full set of Usermacros Generate full set of Usermacros
""" """
macros = [] macros = []
data={}
# Parse the field mapper for usermacros # Parse the field mapper for usermacros
if self.usermacro_map: if self.usermacro_map:
self.logger.debug(f"Host {self.nb.name}: Starting usermacro mapper") self.logger.debug(f"Host {self.nb.name}: Starting usermacro mapper")
@ -119,4 +120,6 @@ class ZabbixUsermacros:
m = self.render_macro(macro, properties) m = self.render_macro(macro, properties)
if m: if m:
macros.append(m) macros.append(m)
data={'macros': macros}
self.logger.debug(f"Host {self.name}: Resolved macros: {sanatize_log_output(data)}")
return macros return macros