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

View File

@ -15,7 +15,7 @@ class ZabbixTags:
self,
nb,
tag_map,
tag_sync,
tag_sync=False,
tag_lower=True,
tag_name=None,
tag_value=None,
@ -130,4 +130,6 @@ class ZabbixTags:
if 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
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):
return data
@ -168,7 +168,8 @@ def sanatize_log_output(data):
if "macros" in data:
for macro in sanitized_data["macros"]:
# Check if macro is secret type
if not macro["type"] == str(1):
if not (macro["type"] == str(1) or
macro["type"] == 1):
continue
macro["value"] = "********"
# Check for interface data

View File

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