Localcheck: multi-line output not display in CheckMK

Hello,

I wrote a local check to read Linux updates (apt, yum, zypper, dnf). I would like to use a multi-line output like https://checkmk.com/cms_localchecks.html#Multi-line%20outputs

The script generates the following output as an example:

P Linux-Updates updates=2;5;10|sec_updates=2;1;3|Sources=2|Locks=0;3;5 2 Updates (kernel-uek-4.14.35-1902.10.8.el7uek.x86_64 kernel-uek-4.14.35-1902.8.4.el7uek.x86_64) \n2 Security Updates \n0 packets are locked \n2 used Paket-Sources

The local agent with this check generate in local-section following output:
<<<local>>>
...
P Linux-Updates updates=3;5;10|sec_updates=2;1;3|Sources=4|Locks=0;3;5 3 Updates (plugins: kernel-uek-4.14.35-1902.10.8.el7uek.x86_64 kernel-uek-4.14.35-1902.8.4.el7uek.x86_64) \n2 Security Updates \n0 packets are locked \n4 used Paket-Sources

P Linux-Updates updates=3;5;10|sec_updates=2;1;3|Sources=4|Locks=0;3;5 3 Updates (plugins: kernel-uek-4.14.35-1902.10.8.el7uek.x86_64 kernel-uek-4.14.35-1902.8.4.el7uek.x86_64) \n2 Security Updates \n0 packets are locked \n4 used Paket-Sources`

on the check-mk-server:
cmk -nv --debug --checks=local hostname

Check_MK version 1.6.0p7
+ FETCHING DATA
 [agent] Execute data source
 [piggyback] Execute data source
....
Linux-Updates        WARN - 3 Updates (plugins: kernel-uek-4.14.35-1902.10.8.el7uek.x86_64 kernel-uek-4.14.35-1902.8.4.el7uek.x86_64) 
OK - [agent] Version: 1.6.0p7, OS: linux, [piggyback] Successfully processed from source '...', execution time 6.9 sec | execution_time=6.943 user_time=0.100 system_time=0.000 children_user_time=0.000 children_system_time=0.000 cmk_time_agent=6.844

Why does checkmk ignore the output behind “\n”?

Edit: I use checkmk 1.6.0p7 Enterprise ; Agent versions are 1.6.0p7

best regards Tux

Look in the status GUI at the “long output of check plugin” line.

2 Likes

Are you aware that there are already official agent plugins at least for apt and zypper?

/opt/omd/sites/SITENAME/share/check_mk/agents/plugins/mk_apt
/opt/omd/sites/SITENAME/share/check_mk/agents/plugins/mk_zypper

But then, a unified approach for “Linux updates in general” surely is nice.

2 Likes

Exactly. And it is safe (yet unnecessary) to install both of them because they won’t output anything if zypper or apt-get isn’t installed on the host.

Hi,

i use this plugins, but these can’t yum and dnf. In addition, the plugins do not meet all my requirements and do not provide a uniform output (between apt and zypper).

Hi r.sander,

where do if find at GUI the “long output of check plugin”

i have find “long output of check plugin (multiline)”

see screnshot:

we can i show this in normal view?

You could edit the view where you see the list of services and add the column for the long output.

Have you code the code so the output has 2 \ ?
Just checking, because when replying is also filter the backslash \\

root@linux# **/usr/lib/check_mk_agent/local/mycustomscript** 2 myservice - CRIT - This is my custom output\\nThis is some detailed information\\nAnd another line with details

@r.sander,

thanks for this idee. it works.

@sirbaas

Yes, i escape \ in the code.

i published my script to github