Special Agent development - Differences between CRE and CCE

Hi,

I’m currently implementing a custom special agent and notices the following strage behaviour. I have been testing this on CRE 2.2.0p20 and CCE 2.2.0p20.

My first question here would be: Is there any documentation about writing special agents? I only found examples by radom people so far, but no real reference documentation about it. I have been reading Writing your own check plug-ins (checkmk.com) but there is not much about special agents there.

About my actual finding:

I’m developing with the free edition in a VM. I created a special agent executable and placed a “wrapper” in “local/share/check_mk/checks/”. This works, but shows the check as “deprecated” in “Analyze configuration”. So I tested if it would work to adjust the check according to what I found on the “Write you own check plug-ins” page. So I modified in and moved it to “local/lib/python3/cmk/base/plugins/agent_based”:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from typing import Any, Mapping, Optional, Sequence

from cmk.base.check_api import passwordstore_get_cmdline
from cmk.base.config import special_agent_info


def agent_anypointplatform(
        params: Mapping[str, Any], hostname: Optional[str], ipaddress: Optional[str]
) -> Sequence[object]:
    args = [
        "--url",
        params["url"],
        "--client_id",
        params["client_id"],
        "--client_secret",
        passwordstore_get_cmdline("%s", params["client_secret"]),
    ]
    return args


special_agent_info["anypointplatform"] = agent_anypointplatform
 Files:                         
   Agent based plugins (Checks, Inventory)
     agent_anypointplatform.py
     anypointplatform_runtimefabrics.py
   Agents
     special/agent_anypointplatform
   GUI extensions
     wato/rulespec_agent_anypointplatform.py
     wato/anypointplatform_runtimefabrics_parameters.py

This way it works fine, in the CCE. I then installed the package in a CRE, and it looked good at first. Package can be installed, enabled, and the service discovery works:

But then activating the change fails, with the message:

Error precompiling checks for host anypoint: Cannot find check file agent_anypointplatform needed for check type agent_anypointplatform

So following status:

  • Installing and enabling plugin works on CRE and CCE
  • Service discovery works on CRE and CEE (so it is actually able to use the script)
  • Enabling the change fails on CRE, but works fine on CCE.

So I moved “agent_anypointplatform.py” from “agent_based” to the legacy “checks” directory and removed the .py extension, and it’s working also on CRE now.

So I was wondering:

  • Is this known, expected behavior?
  • Where would I find the official documentation about this? I found a forum posting stating that the wrapper scripts of special agents always have to be placed in the legacy “checks” directory. I wonder if I missed that in the documentation.

Regards,
Sven

Hi,

until checkmk 2.2 this was not documented.
I would recommend to develop the special agent in a daily build of checkmk 2.3
Special Agents are called “server side calls” now and they build a new API and documentation which is inside the checkmk Installation itself in help - check Plugin API Reference - server side calls.

Then you develop against a versioned API and hopefully don’t need to change things in the future, what you definetly will have do when you develop with older versions of checkmk.

1 Like

Some Info about the upcoming changes :

Andreas already ported his redfish plugin to the new api, you can use this as an example:

2 Likes