Fix plugin config lookup shadowed by CLIENT_DEFAULTS plugins key

CLIENT_DEFAULTS seeds "plugins": {} so raw_config.get("plugins", raw_config)
always returned the empty subdict instead of falling back to the full config.
Plugins configured at top-level (e.g. nagios_runner: ...) were therefore
never found, resulting in "No Nagios commands configured".

Now checks the plugins subdict first, then top-level keys, so both
config layouts work correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-24 12:58:42 +02:00
parent 990c658e65
commit 1a470e7cfa
+7 -5
View File
@@ -312,9 +312,10 @@ class PluginLoader:
loaded_count = 0 loaded_count = 0
raw_config = config or {} raw_config = config or {}
# Per-plugin config lives under the 'plugins' key; fall back to top-level # Per-plugin config lives under the 'plugins' key or at top-level.
# for backwards compatibility. # CLIENT_DEFAULTS seeds "plugins": {} so the key always exists; check
plugin_config = raw_config.get("plugins", raw_config) # both the subdict and top-level so that either layout in .hbc.yaml works.
plugins_subconfig = raw_config.get("plugins", {})
# Scan for Python files # Scan for Python files
for plugin_file in directory.glob("*.py"): for plugin_file in directory.glob("*.py"):
@@ -359,8 +360,9 @@ class PluginLoader:
self.logger.debug(f"Found plugin class: {name}") self.logger.debug(f"Found plugin class: {name}")
# Instantiate plugin with config # Instantiate plugin with config — check plugins subdict first,
plugin_instance_config = plugin_config.get(obj.name, {}) # then top-level keys (e.g. nagios_runner: ... at root of config).
plugin_instance_config = plugins_subconfig.get(obj.name) or raw_config.get(obj.name, {})
plugin = obj(config=plugin_instance_config) plugin = obj(config=plugin_instance_config)
# Initialize plugin # Initialize plugin