Create a host label in an active check

In one of our active checks we would like to create some host labels.

One method would be to create a file in the spool folder which then will be picked up by the agent.
But… by default, the active check (running as site-user) has no permission to write to the spool folder (owned by root:root, mode 0775). Sure we can change the permissions, but they will be reset at next agent update.

So the idea would be to somehow “directly” create the labels within the active check. But how?


P.S.: of course the active check is written in Python :slight_smile:

An active check cannot create host labels.

I don’t know how complex your active check is or what it does, but you could:

  • Rewrite the Active Check into a Datasource Program/Special-Agent, where you can add labels freely in the Agent-Section definition with a host_label_function
  • Run whatever it is the Active Check is doing as an Agent Plugin that is executed on the Monitoring Server and assign the Output as piggyback-data to the destination-host. You can then also append a <<<label>>>-section to the agent-output and enclose it as piggyback-data. That way the label will be assigned to the corresponding host.

Again, these are just some ideas and what might be possible depends entirely on what you are doing in your active-check.

1 Like

As you said, it depends on what the check is doing :slight_smile: sadly we can’t run this kind of check on the agent. But we are considering rewriting the check to be a special agent (haven’t yet thought about this, thanks!!)

1 Like