Inside a custom plugin, is there a way to tell what host is being discovered?

I’d like to be able to populate service labels via a lookup file, but it requires knowing what host’s services are being discovered.

I’m diving into plugins, and utils trying to find the answer for myself but just thought I’d ask.

There is a method host_name() unofficially available for check plugins. You can import it from cmk.base.check_api .

But I would recommend against such “side effects” in check plugins.

If you have a lookup file on the monitoring server (or somewhere else) with the label data it may be possible to create an agent plugin that outputs piggyback data for the hosts containing <<<label>>> sections.

You could even put label data in spool files and place them in /var/lib/check_mk_agent/spool.

Thanks that makes sense to play it safe and do this elsewhere!

What do you think of creating the “Service Discovery Rules” that would add the service labels? This would be nice because then other people could modify those as required in the GUI.

I’m not seeing a place to update or add those via the REST-API, but it has to be possible somewhere to do it via automation.

The “Process Discovery” ruleset is now able to set labels. You could use it as an example.