Automatic host labels (os for example)

I would like to differentiate between windows and linux hosts (and others). I could create a custom attribute ‘os’, but it seems to me there should be a way for checkmk to automatically detect the OS?

I see the following output for example for the agent:

<<<check_mk>>>
Version: 1.6.0p6
BuildDate: Nov 11 2019
AgentOS: windows

So would it be possible to automatically create a host label os:windows or something that I can then use in rules? If yes, how do I configure this?

Angelo.

Hi,
I think (I hope) that the new feature “Automatic Labels” for the operating system will be available in CMK 1.7. There has been a section about this feature in the CMK manual - but this has been removed a few days ago.

Karl

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