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 <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,7 @@ class NagiosRunnerPlugin(MonitorPlugin):
|
|||||||
self.logger.info(f"Initializing {self.name} plugin")
|
self.logger.info(f"Initializing {self.name} plugin")
|
||||||
|
|
||||||
if not self.commands:
|
if not self.commands:
|
||||||
|
self.skip_reason = "no commands configured (add nagios_runner.commands to config)"
|
||||||
self.logger.info("No Nagios commands configured")
|
self.logger.info("No Nagios commands configured")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user