Automatic host labels (os for example)

You can put a spool file in /var/lib/check_mk_agent/spool which contains a section labels.

Example:

<<<labels:sep(0)>>>
{"os": "Ubuntu"}

It is important that you use 0 as separator and place the label definition(s) into one line, formatted as JSON. To add multiple host labels, add the definition to one of the lines or put separate definitions into separate lines (or both), like this:

<<<labels:sep(0)>>>
{"os": "Ubuntu", "role": "webserver"}
{"location": "Munich"}

Checkmk 1.6.0p5 (and possibly earlier versions) already ship with a server side “check” that interprets these labels sections. The data is read line by line, interpreted as a JSON dictionary and mixed into a dictionary with the host labels. Multiple sections of the same name and/or multiple lines are combined.

I know this isn’t fully automatic because you have to create that spool file yourself, but maybe it helps anyway.

5 Likes