CMK version: Checkmk Enterprise Edition 2.3.0p28
OS version: CheckMK Virtual Applience
Issue Description
I’ve developed a special agent for REST API monitoring that works correctly with a single rule, but when I configure multiple rules for the same host, only the first rule is executed. I need to monitor multiple REST API endpoints on the same host, each with different configurations.
Specific Behavior
- When I create multiple “Generic REST API Agent” rules for the same host, only the first one is processed
- The rules are all active and should all match the host
- Each rule has a different URL and service name
- The agent_restapi script works correctly when called manually with each set of parameters
Current Implementation
My current implementation has three parts:
- Server-side call handler in agent_restapi.py
def _agent_arguments(params, host_config):
args = ["--url", str(params["url"])]
# Service Name
if params.get("service_name"):
args += ["--service-name", params["service_name"]]
# [Additional parameters processing...]
yield SpecialAgentCommand(command_arguments=args)
special_agent_restapi = SpecialAgentConfig(
name="restapi",
parameter_parser=noop_parser,
commands_function=_agent_arguments,
)
- Ruleset definition in agent_restapi.py
- Agent executable in agent_restapi
Testing Attempts
I’ve tried to modify the _agent_arguments
def _agent_arguments(params, host_config):
# Handle multiple rules
if isinstance(params, list):
for single_params in params:
yield from _build_command(single_params)
else:
# Single rule case
yield from _build_command(params)
def _build_command(params):
args = ["--url", str(params["url"])]
# [Build arguments...]
yield SpecialAgentCommand(command_arguments=args)
However, this doesn’t seem to help - only one rule is still being processed.
Specific Questions
- Does Checkmk 2.3 pass multiple rules as a list to _agent_arguments
- If yes, then my implementation should work but something else is wrong
- If no, how are multiple rules processed?
- Is there a debug mode to see how rules are being passed to special agents?
- I need to understand what params contains when multiple rules match
- Are special agents limited to one execution per host?
- Is there a design limitation I’m missing?
- Do I need to register my special agent differently for multiple rule support?
- Is there a parameter I need to add to SpecialAgent() in the ruleset definition?
- What’s the best way to debug special agent rule processing?
- Is there a log file or debug flag I can enable?
What I’ve Tried
- I’ve confirmed all rules are active in the UI and match the host
- Each rule has unique parameters (URL, service name, etc.)
- When called manually with each set of parameters, the agent works correctly
- When deployed, only the first rule runs successfully
Any insights would be greatly appreciated! Thank you!