From 94e15979780f0f8bfe55fa7cbbbe404071caa625 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Sat, 25 Apr 2026 16:13:03 +0200 Subject: [PATCH] feat: set skip_reason on nagios_runner when no commands configured When NagiosRunnerPlugin has no commands configured, set skip_reason before returning False from initialize(). This allows PluginLoader to log INFO (not WARNING) when the plugin is skipped. Co-Authored-By: Claude Sonnet 4.6 --- hbd/client/plugins/nagios_runner.py | 5 +++-- tests/test_nagios_runner.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/test_nagios_runner.py diff --git a/hbd/client/plugins/nagios_runner.py b/hbd/client/plugins/nagios_runner.py index 566522f..64301f6 100644 --- a/hbd/client/plugins/nagios_runner.py +++ b/hbd/client/plugins/nagios_runner.py @@ -87,13 +87,14 @@ class NagiosRunnerPlugin(MonitorPlugin): async def initialize(self) -> bool: """Initialize the Nagios runner plugin. - + Returns: True if at least one command is configured, False otherwise """ self.logger.info(f"Initializing {self.name} plugin") - + if not self.commands: + self.skip_reason = "no commands configured (add nagios_runner.commands to config)" self.logger.info("No Nagios commands configured") return False diff --git a/tests/test_nagios_runner.py b/tests/test_nagios_runner.py new file mode 100644 index 0000000..4656a5e --- /dev/null +++ b/tests/test_nagios_runner.py @@ -0,0 +1,22 @@ +import asyncio +import logging +import os +import stat + +import pytest + +from hbd.client.plugins.nagios_runner import ( + NagiosRunnerPlugin, + NAGIOS_OK, + NAGIOS_WARNING, + NAGIOS_CRITICAL, + NAGIOS_UNKNOWN, +) + + +def test_no_commands_sets_skip_reason(): + plugin = NagiosRunnerPlugin(config={"commands": []}) + result = asyncio.run(plugin.initialize()) + assert result is False + assert plugin.skip_reason is not None + assert "nagios_runner.commands" in plugin.skip_reason