Configure custom agent plugin in WATO and write to /etc/checkmk/my_plugin.cfg

Hello,

I am writing here after searching docs and The Web for a while now without result. So I try to find an answer here. The question is: how can I configure a custom plugin in WATO and bake certain config into an agent, so that this config will be placed in /etc/check_mk at the remote host?

In detail, I want to be able to set a variable KUBECONFIG file path in WATO and get it down onto the host. It should be read in checkmk-agent-plugin-kubernetes-namespaces/mkp/agents/plugins/kubernetes_namespaces.py at kubeadmin-var · HenriWahl/checkmk-agent-plugin-kubernetes-namespaces · GitHub.

Is this somehow possible or is there another way to get a config from WATO to the agent plugin?

Thanks for any hint - Henri

Hi Henri,

yes, you can do that.
In 2.3 you can use the new bakery api to achieve that. The API Documentation can be found in you site in help - “Plugin API references”.

There is an example integration for different operating systems.
Further examples can be found in the checkmk exchange. I think e.g. the sslcertificates MKP by Robert does exactly that for linux systems.

@aeckstein thanks for the hint! Basically this means on older setup with 2.2.0 there is no way to do so? I just found other configs like mk_inventory.cfg on the host in /etc/check_mk but did not find out how they got there. Maybe the are provided by core Checkmk.

The following Link shows a small example from one of my plugins with config file generation in 2.1.

This should also work the same way in 2.2.

1 Like

Hi Henri,

it is also possible to do the same in checkmk 2.2.
You can look into /lib/python3/cmk/base/cee/plugins/bakery like
grep -r "yield PluginConfig" /opt/omd/versions/<your version>/lib/python3/cmk/base/cee/*

There are a lot examples how and what can be achieved.

I would also look into MKP packages in the checkmk Exchange where that problem has already been solved e.g. the ceph or the sslcertificates plugin.

If you only want to deploy the config you will need:

  1. The valuespec definition to set the needed values with a rule - /web/plugins/wato/yourplugin.py
  2. The bakery configuration to deploy the configuration file into the package - /lib/python3/cmk/base/cee/plugins/bakery/yourplugin.py
1 Like

Thanks to all of you - your comments helped me to get the config done! :+1:

Can you please mark the answer as the solution if it solved your problem?

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.