Special agent not found

CMK version: 2.0.0p23
OS version: GNU/Linux (docker)

Error message:

Program '/omd/sites/cmk/share/check_mk/agents/special/agent_myspecial' not found (exit code 127)

Output of “cmk --debug -vvn hostname”:

[ProgramFetcher] Execute data source
Calling: /omd/sites/cmk/share/check_mk/agents/special/agent_myspecial '-a' '1.2.3.4.5' '-p' '20'
[cpu_tracking] Stop [7f56a1d3bd30 - Snapshot .......]
Program '/omd/sites/cmk/share/check_mk/agents/special/agent_myspecial' not found (exit code 127)

Given the error message, I double checked, and indeed my special agent is locatedlocated at the location specified where it is missing from. The file is executable (+x) and belongs to the site user (cmk:cmk). My guess is that since is a python code, I must do something special in order for the code to be executed as python instead of bash. However, I found no information how to do it, and in general very little information on how to build and configure my own special agent.

Special agent - Target: /omd/sites/cmk/local/share/check_mk/agents/special/agent_myspecial

#!/usr/bin/python3

import argparse
if __name__ == '__main__':
    arg_parser = argparse.ArgumentParser()
    required_param_group = arg_parser.add_argument_group('required arguments')
    required_param_group.add_argument('-a', '--adress_ip', required=True, help="Host adress")
    required_param_group.add_argument('-p', '--port', required=True, help="Port number")
    args = arg_parser.parse_args()

    print('<<<myspecial_response_code>>>')
    print('200')

WATO - Target: /omd/sites/cmk/local/check_mk/web/plugins/wato/myspecial_register.py

#!/usr/bin/python

from cmk.gui.plugins.wato import (
    IndividualOrStoredPassword,
    RulespecGroup,
    monitoring_macro_help,
    rulespec_group_registry,
    rulespec_registry,
    HostRulespec,
)
from cmk.gui.valuespec import (Dictionary, Integer)

from cmk.gui.plugins.wato.datasource_programs import RulespecGroupDatasourcePrograms

def _valuespec_special_agent_myspecial():
    return Dictionary(
        title=_("My Special Agent"),
        help=_("This agent is responsible for check if something response on given http port"),
        elements=[
            ("port", Integer(title=_("HTTP port"))),
        ],
    )

rulespec_registry.register(
    HostRulespec(
        group=RulespecGroupDatasourcePrograms,
        name="special_agents:myspecial",
        valuespec=_valuespec_special_agent_myspecial,
    )
)

Argument-thingy - Target: /omd/sites/cmk/local/share/check_mk/checks/agent_myspecial

#!/usr/bin/env python3

def agent_myspecal_arguments(params, hostname, ipaddress):
    args = []

    args += ["-a", ipaddress]
    args += ["-p", params['port']]

    return args

special_agent_info['myspecial'] = agent_myspecal_arguments

Check - Target: /omd/sites/cmk/share/local/lib/check_mk/base/plugins/agent_based/myspecial_response_code

#!/usr/bin/python

from .agent_based_api.v1 import (
    register, Service, Result, State
)
from cmk.utils import debug
from pprint import pprint

def discovery_myspecial_response_code(section):
    if debug.enabled():
        pprint('Discovered')
    yield Service()

def check_myspecial_response_code(params, section):
    yield Result(state=State.OK, summary="Found the service!")

register.check_plugin(
    name="myspecial_response_code",
    service_name="Myspecial - response code",
    discovery_function=discovery_myspecial_response_code,
    check_function=check_myspecial_response_code,
    check_ruleset_name='myspecial',
    check_default_parameters={'port': 20}
)

At this location, no such a file, should exist. That’s correct.
This file is only allowed in the folder.

/omd/sites/cmk/local/share/check_mk/agents/special/

And it must be executable.

Your wrong path will be created if the agent file in the local folder is not executable for the site user.

Sorry, this was a typo. I had to type it manually into a different computer. The scripts are all placed in the local subdirectory: /omd/sites/cmk/local/....

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.