Multiple Special Agent Rules for Same Host Not All Executing

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:

  1. 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,
)
  1. Ruleset definition in agent_restapi.py
  2. 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

  1. 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?
  1. 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
  1. Are special agents limited to one execution per host?
  • Is there a design limitation I’m missing?
  1. 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?
  1. 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

  1. I’ve confirmed all rules are active in the UI and match the host
  2. Each rule has unique parameters (URL, service name, etc.)
  3. When called manually with each set of parameters, the agent works correctly
  4. When deployed, only the first rule runs successfully

Any insights would be greatly appreciated! Thank you!

No - only one special agent of a specific type can be assigned to a single host. Beside this it is possible to assign multiple different special agents to one host.

Yes - one agent per agent type

What i would do is a rework of your rule for the special agent, that it is possible to submit multiple endpoint to query in one rule.

On command line do a “cmk --debug -vvD hostname” to see what your special agent rule outputs.

I just want to emphasize that a special agent is used to switch from CheckMK agent or snmp to a totally different way to collect data from a host. These special agent should collect and output all data required at once and local checks are than used to extract services and states from this output. Another way would be to create one or more active legacy checks to request data via REST-API and create services from this.