Automatically activate service after discovery using plugin

Hi everyone,

is it possible to automatically add a service to the list of monitored services after it has been discovered using a custom plugin?


you can add “manual checks/enfoced service” to monitor your resource. Than, no discovery is needed.

Kind regards,

Not sure about the “custom plugin” you mentioned. Perhaps you can explain your requirements in more detail?

In general, you can configure the “Periodic service discovery” ruleset to not only regularly check for new services but also to automatically add them and activate changes.

(section “Adding services automatically”)

Thanks for the help so far. Ideally it should work like this:

On a host are x instances of an application running and not all of them should be monitored. Which one of these should be monitored is determined by another application that saves this info in a database. The checkmk plugin on the host gets this information plus the payload (the state info of the applications) and Checkmk fetches this info. My custom plugin running in Checkmk now creates separate services with labels, etc. that are discovered but I still have to activate them manually.
Ideally at this point I´d like to tell Checkmk in my custom plugin that there are new services to be monitored and that they should be activated automatically as soon as they are discovered.

@ChristianM I tried setting up an enforced service but this seems to be bound to one item/service. So discovery/activation of several instances of the same service didn´t work. But maybe I misunderstood. I tried tweaking these discovery rules, but it seems I´d have to lower the interval down to 1 minute to be able to get the services as instantaneous as possible. Also I like to deactivate this option because it always creates a warning because of discovered but unmonitored services. The option to set it to OK in this case dowesn´t seem to work.

Normaly the “Periodic service discovery” rule would be the a good place to start. But you can only have one active “Periodic service discovery” rule per server at the same time (first matching rule defines the parameter)

But in this specific case the rest API might be worth a try like [andreas-doehler] described in this post:

@LaSoe Thank you for the hint. I tried the Rest Api and it seems to work in general. E.g. getting services works but changing the phase doesn´t. The python script I tested yielded ‘Done’, so I don´t believe the script is wrong, but neither ‘monitored’ nor ‘ignored’/‘vansihed’ seem to work. If it is a bug, then I have to wait for the next version.

Do you know if PUT …/invoke worked in an earlier release?

This bug. I was reporting this in the mentioned post but nothing until now.

I´d like to add something here (and I´m hoping not to overstress this post :slight_smile: ).

Setting the phase of a service with Rest to monitored, vanished, ignored, etc. works fine for services within the group Services->Catalog of check plugins->Operating Systems->Linux-> Filesystems, Disks and RAID but not with services of other groups (at least the ones I tried).
When trying to set the phase of services from other groups i also get a response 204, which should be ok but this change is not recognised in Checkmk.

Maybe there is a setting somewhere to enable phase change via Rest for specific groups?

(I´m on 2.0.0p20)

EDIT: Sorry, it only seems to work for df and mounts (maybe all built in plugins?). I tried adding my own plugin to this group and it didn´t work.

Any chance the bug Andreas mentioned early is fixed in version 2.1? Does anyone have any information on this? (Sorry for reviving an old post)