How to package an agent under /usr/lib/check_mk_agent/plugins

Hi,

I am writing a custom plugin for check-mk-raw:2.2.0-latest, by using the dockerized version, and following the official guide.

Basically, I have two files:

  • The data collector, i.e. the agent plugin, which goes under /usr/lib/check_mk_agent/plugins
  • The data parser, i.e. the agent_based plugin, which goes under local/lib/check_mk/base/plugins/agent_based

It works just fine.

Now I like to create a mkp package, to be able to easily install and update the plugin from the development environment to production.
I have created a “package manifest” by running mkp template, and I like to fill its files section to include both the parser and the collector. But unfortunately:

  • There is the agent_basedkey for the parser
  • I do not know any key for the collector

How can I do?

Thank you,
regards

1 Like

I do not understand the question. What do you mean with “key for the collector”?

Hi,

I mean basically this:

{
    "author": "Gizero <info@gizeroenergie.it>",
    "description": "Agent Plugin and Checks for ResIoT Gateways",
    "download_url": "https://bitbucket.org/gizeroenergie/checkmk-gw-resiot",
    "files": {
        "agent_based": ["my_plugin.py"],
        "agents": [],
        "checkman": ["my_plugin"],
        "gui": [],
        "lib": [],
        "???": ["my_plugin"] //<-- this is the "collector", placed under /usr/lib/check_mk_agent/plugins
    },
    "name": "my_plugin",
    "title": "My Plugin",
    "version": "1.0.0",
    "version.min_required": "2.2.0p7",
    "version.packaged": "2.2.0p7",
    "version.usable_until": "None"
}

What to place instead of ??? ?

My “collector” basically performs a REST API call to have the status of a list of devices, and the “parser” manipulates the results to prepare them for Checkmk.
I am not even sure this is actually the most correct way to create the plugin… but at least it seems to work…

Thank you,
regards

Place your agent plugin in $OMD_ROOT/local/share/check_mk/agents/plugins and mkp should pick it up.
The entry for the files section in the manifest is this:
'agents': ['plugins/youragentplugin'],.

BTW: Creating agent packages is very easy with the web based GUI in the enterprise edition. You could install the CCE (cloud edition turning into the free edition) for your development site.

1 Like

Hi,

thank you for the suggestion, but it does not work properly.
Basically, it packages, and install fine, but then:

  • I go to “hosts”
  • I create a new host, “localhost”
  • I click the “save & discovery” button
  • I run the reload of changes
  • But then nothing appears on the dashboard

If instead I do the same by placing the file in /usr/lib/check_mk_agent/plugins, and I do the same steps, in the dashboard I get the check results.

Maybe it means that I have do perform a different setup/steps list?

Thank you,
regards

This does not cover the deployment of the agent plugin to the monitored host. It only makes it possible to include the plugin file in the MKP package.

How the plugin file will be deployed to the host depends on the checkmk edition. With the RAW edition you will have to do it by hand (or via Ansible, Puppet, etc).
With the Enterprise edition you can use the agent bakery and the agent updater to do it, but you would need an additional bakery plugin with an accompanying ruleset.

1 Like

Hi,

ah now that’s clear.
So basically, after installing the plugin, I have to copy the file from $OMD_ROOT/local/share/check_mk/agents/plugins to /usr/lib/check_mk_agent/plugins, and then the performed setup will work just fine.

Thank you,
Regards

1 Like