Where to locate self-made special agents in CMK 2.3

Hi Checkmk community

For self-made special agents which query some REST APIs, I’m trying to do it the new way of using the CMK 2.3 Plugin API. But I don’t even get where to place them - as I cannot find it in any documentation.

Let’s start with the example in CMK UI > Help > Plug-in API references > Server-side calls:

  1. Is this example still correct and should it work? For instance, there is no shebang line.
  2. Do I have to place those two files in some “addons” folder as discribed in some forums?
  3. Are some file permissions to be set?
  4. How to activate the example special agent and where does it appear in the UI?
  5. What does the example do? Does it query some REST APIs at it is a server-side plugin?

Please don’t refer to any Git repos as they don’t explain where the self-made special agents have to be placed.

Thanks
Cntux

Why not - i use one of my simple special agent checks if i write something new.
This here is an example of a very simple special agent based check in the new folder structure.

Relevant for the special agent are the folders.

  • libexec
  • server_side_calls
  • special_agents
1 Like

Hi @cntux ,

for 2.3 new plugin development should be located in

~/local/lib/python3/cmk_addons/plugins/<plugin_name>

Here you separate your files accordingly :
…/<plugin_name>/agent_based/
…/<plugin_name>/checkman/
…/<plugin_name>/rulesets/
…/<plugin_name>/server_side_calls/
…/<plugin_name>/special_agents/
…/<plugin_name>/libexec/
…/<plugin_name>/(…)

You have a good plugin to check as template on exchange - maybe it helps you going further on developing :

https://exchange.checkmk.com/p/workshop-conf10

Hope it points you in the right direction.

2 Likes

Let’s recap:

  • this folder path is also used for a self-written special agent
  • the python module fetching the REST data must be stored in lib/ and be called “agent.py” (EDIT: it depends what is defined in libexec/agent_-name- but this naming makes sense)
  • the API doc is therefore useless or even outdated

Thanks for any advice and in my opinion a bit much magic without docs…

1 Like

This has nothing to do if it is a special agent or not. Every own extension to CheckMK should be under this path.

No
libexec path → stub file with name defined inside “server_side_call”, executing the Python main function from the real special agent inside “special_agents” folder

No
The API doc only describes what you need to do inside the “server_side_call” file. Nothing else.

1 Like

The base is “~/local/lib/python3/cmk_addons/plugins/”. The folder of the plugin is “vsan” here.
grafik

The concept is:

  1. The script “server_side_calls/agent_call.py” is responsible to generate the commandline :


    (which you can see when you excute “cmk -vvv --debug HOST”)

  2. which calls the wrapper ~/local/lib/python3/cmk_addons/plugins/vsan/libexec/agent_vsan
    grafik

  3. which executes the main() method in “special_agent/agent.py”

In my case main() executes pyvmomi calls which output checkmk agent sections.

1 Like

Why do you seperate the special agent from the libexec wrapper? what is the purpose of this? I’ve coded the agent directly into the executable in the libexec folder and it works fine. I might be missing something though…

I’m just a deep dive customer. I just tried to understand this concept from examples and currently streamline all extensions to this structure. When something is dropped or enforced in the next version there is less hassle to update it.

And: When I move my “special_agent/agent.py” to “libexec/agent_vsan” I have no syntax highlighting in vi (when highlighting is based on file extension) and makes changes more difficult.

1 Like