Werk #16259: New APIs for plugin development

Component Checks & agents
Title New APIs for plugin development
Date Feb 26, 2024
Level Prominent Change
Class New Feature
Compatibility Compatible - no manual interaction needed
Checkmk versions & editions
2.4.0b1
Not yet released
Checkmk Raw (CRE), Checkmk Enterprise (CEE), Checkmk Cloud (CCE), Checkmk MSP (CME)
2.3.0b1 Checkmk Raw (CRE), Checkmk Enterprise (CEE), Checkmk Cloud (CCE), Checkmk MSP (CME)

Checkmk 2.3 features new APIs for plugin development. There are three new APIs, and a new version of the agent based API (also known as "Check API"). The replaced APIs will not be supported after 2.3 (details below).

Plugin APIs in general provide means to write own code that interacts with the main application using well defined and stable code libraries.

While Checkmk has always offered the possibility to add custom plugins, the APIs were often ad-hoc and undocumented. In Checkmk 2.0 we started to address this with the introduction of the agent-based API. With this werk, all important elements of creating your own monitoring plugins are covered by an API.

With the APIs we introduce here we clarify what is meant to be used by plugin developers and what are internal modules, which can and likely will change over time and should not be used. This is beneficial for all involved parties:

  • Checkmk developers can easily figure out what parts of the code can be changed without breaking plugins. We can focus on providing stable APIs while gaining the freedom to rapidly refactor the backend code.
  • Plugin developers know what features to use to prevent their plugin from unexpectedly breaking during an upgrade, without having to closely follow the changes we make to the code.
  • Checkmk users can have reliable information on which of their extensions will continue to work after a major upgrade.

As a result, the increased transparency leads to a better stability and hence a better user experience on all sides.

While the APIs are also intended to be stable, the main focus now is on transparency. All of the APIs have a limited scope, and we have tried to have them feature complete within these limits. However, as the development of Checkmk progresses, we might have to add some features or redesign others. The versioning of the APIs will allow us in these cases to maintain the old version (for a while) and provide documentation on how to migrate to the newer API version.

While we recommend testing the APIs and highly appreciate any feedback: Be aware that during the beta phase incompatible changes to the APIs might occur. Start with a small subset of your plugins to check out the APIs capabilities and limitations. Wait for the stable release before migrating a large amount of plugins to avoid having to make adjustments in all of them.

You can find a detailed technical documentation of the APIs in a running sites "Help" menu, under "Plugin API references".

Compatibility

For all affected plugins (see below) the following migration timeline is supported:

For Checkmk 2.3 we tried our best to ensure all plugins will continue working as in 2.2. Note that we can't guarantee all plugins will work for the above reasons.

We strongly recommend users migrate to the new APIs during the lifetime of 2.3.

With the update to 2.4 all measures to ensure that older plugins still work are dropped, effectively making it extremely unlikely that these plugins will continue to work.

General changes and common API properties

The main changes of these APIs is to reduce side effects when importing the code (for better testablility) and allow for a better component oriented structure:

  • We move away from the "registry" approach we had in the past, to a discovery based approach. Plugins are instances of specific classes that are created in a certain place with a certain naming scheme.
  • All plugins (rulesets, check plugins, metrics, ...) of the same "plugin family" can now live in a common folder.

A detailed description can be found in the technical documentation mentioned above.

Plugins already migrated by us can be found in the cmk/plugins folder of the source code.

Rulesets API: cmk.rulesets.v1

This is the new API for the creation of rulesets used by the users to configure their plugins. The supported Ruleset types and input form elements can be found in the technical documentation. These are the plugins formally known to sit in your sites local/share/check_mk/web/plugins/wato. To be discovered by Checkmk they now have to be in local/lib/python3/cmk_addons/plugins/<YOUR PLUGIN FAMILY NAME>/rulesets.

Graphing API: cmk.graphing.v1

This is the new API for the creation of objects required for metric visualization, such as perfometers and graphs. The supported metric objects can be found in the technical documentation. These plugins previously where located at local/share/check_mk/web/plugins/metrics. To be discovered by Checkmk they now have to be in local/lib/python3/cmk_addons/plugins/<YOUR PLUGIN FAMILY NAME>/graphing.

Server side calls API: cmk.server_side_calls.v1

This is the new API for plugins that convert a configured ruleset for a special agent or active check to the command line command that is used to run the special agent or active check. Details on the exposed classes and their usage can be found in the technical documentation. These plugins previously where located at local/share/check_mk/checks, and filled a special_agent_info or active_check_info dictionary. To be discovered by Checkmk they now have to be in local/lib/python3/cmk_addons/plugins/<YOUR PLUGIN FAMILY NAME>/server_side_calls.

New version of agent based API: cmk.agent_based.v2

The new version of the agent based API was mostly added to increase consistency with the other three APIs (discovery mechanism, plugin location). It also features a couple of less important improvements. Details can be found in the technical documentation. These plugins previously where located at local/lib/check_mk/base/plugins/agent_based. To be discovered by Checkmk they now have to be in local/lib/python3/cmk_addons/plugins/<YOUR PLUGIN FAMILY NAME>/agent_based.

To the list of all Werks