CheckMK Local Check Details Output not working

2.2.0p22:
Oracle Linux 9:

Hi Community,
i just developed a new Local Check and noticed that checkmk doesnt output the Details anymore.

Example Output:

<<<local:sep(0)>>>
P "My service" humidity=37;40:60;30:70 My service output
A line with details
Another line with details

My Example Python Code:
/usr/lib/check_mk_agent/local/backupcheck.py

print("<<<local:sep(0)>>>")
print('P "My service" humidity=37;40:60;30:70 My service output\nA line with details\nAnother line with details')

My Detail Output is missing in the Check:

How can i fix that issue?
Can anyone explain me please what i did wrong?

I was following the following guide:

Thank you,

“P” what does that stand for?

P stands for i dont know haha

Usually i use 0,1,2 but for this post i just copied the code from the official documentation.
My Service goes to warning and works but the detail output is missing :frowning:

You have to output a literal \n and not a newline.

3 Likes

P advises the local check plugin to use the thresholds from the metrics (aka Performance data) to compute the service state.

2 Likes

From the documentation :

If you pass the letter P instead of a number in the first field of the output that determines the state, the service’s status will be calculated on the basis of the threshold as provided.

Is that really, what you want to achieve ?

1 Like

And i dont think that you need to print the local header if your Script is run from inside the local folder.

1 Like

@aeckstein the code is just an example. My problem is just the missing Details Output. Not sure why it isnt working anymore. Instead of writing the Details into the check, the monitoring tries to create another service instead.

This is not necessary, as the output of the scripts executed as local plugins is automatically in the local section.

My local script in /usr/lib/check_mk_agent/local/ :

#!/bin/bash
echo "P \"My service\" humidity=37;40:60;30:70 My service output\nA line with details\nAnother line with details"

The result:

grafik

Tested on 2.2p17 and 2.2p23.

2 Likes

So it is as Robert said: for multiline output in a local check you have to print a literal \n.
That’s two characters: a backslash and a single n, not an escaped newline character.

In Python that would be:

print('P "My service" humidity=37;40;60;30;70 My service output\\nA line with details\\nAnother line with details')
                                                               ^^^                   ^^^

In shell (echo command) no such double backslash is needed because the echo command doesn’t know about such special characters anyway and doesn’t interpret them. So there echo "...\n..." is sufficient to print a literal backslash followed by a literal n.


Btw: the numbers in the metric must all be separated by semicolons. The colons in the original post were wrong:

Wrong: `humidity=37;40:60;30:70`
                      ^     ^

Right: `humidity=37;40;60;30;70`

Update: forget about this statement about colons and semicolons.

These define the thresholds for the calucation of the check status : 
Some parameters have not only an upper threshold but also a lower threshold. An example is humidity. For such cases the local check has the option of passing two threshold values each for the states WARN and CRIT. They are separated by a colon and represent the lower and the upper threshold value respectively.
3 Likes

I stand corrected. Now I see my mistake. Given that line:

humidity=37;40:60;30:70

I thought this is supposed to mean

WARN=40, CRIT=60, MIN=30, MAX=70.

But it actually means

WARN_lower=40
WARN_upper=60
CRIT_lower=30
CRIT_upper=70
MIN=unset
MAX=unset

Sorry for the confusion.

2 Likes

Thank you to all guys :slight_smile:

I forced my python script to return the \n values instead of returning a new line.
Its working now.

Regards,

1 Like