Executing a parameterized check from a monitored host (not CMK server)

Hello everyone,

I need to develop a plugin, which has the following attributes:

  • Executed from a monitored host instead of the CMK server
  • Must be distributable via agent bakery
  • Must be configurable with service monitoring rule

First, I’d like to make sure that I get the correct kind of check here: Since it has to be executed remotely and not on the CMK Server, my understanding is that what I need is an “agent-based ckeck-plugin”, since most of the other kind of checks are either executed from the CMK server directly or have to be manually saved in specific folders (which makes distribution via agent bakery impossible).
Is this correct?

Assumed this is correct:
I am pretty much done with the development of the plugin. The goal is to have the script execute a tcp-port-scan just as the native “check_tcp” check is doing it, but executed from the remote host instead of the CMK Server (which seems not to be possible with the existing check).

I have successfully achieved most things: The agent plug-in is working and provides the results in the agent output, the check plug-in successfully parses the returned values including response time metrics and the service monitoring rules for different port states and response time thresholds are successfully evaluated.
The only thing missing is that the agent plugin is currently scanning a hardcoded IP and Port. How can I achieve these two parameters to be configurable in the service monitoring rule and have the agent plug-in use these instead of the hardcoded values?

There is a ruleset to configure MRPE in the agent bakery. This should do what you need.
The Nagios plugin can be distributed with the agent package.

If you really want to use an agent plugin you need to create a ruleset for the bakery and a bakery plugin that adds the agent plugin plus a configuration file to the agent package. Your agent plugin then reads the configuration file and uses whatever is configured there.

An example is our SSL certificates extension.

Bakery ruleset: check_mk_extensions/sslcertificates/rulesets/sslcertificates.py at cmk2.5 · HeinleinSupport/check_mk_extensions · GitHub

Bakery plugin: check_mk_extensions/sslcertificates/lib/python3/cmk/base/cee/plugins/bakery/sslcertificates.py at cmk2.5 · HeinleinSupport/check_mk_extensions · GitHub

Reading the config file in the agent plugin: check_mk_extensions/sslcertificates/agents/plugins/sslcertificates at cmk2.5 · HeinleinSupport/check_mk_extensions · GitHub

3 Likes

Thank you very much for your fast and on-point answer!
This helped me a lot! :clap:

1 Like