Local check with cache

Dear CheckMK Community,

once again, I am in need for advice.

I created a local check with a cache lifetime of 24h.
The check monitors if all the letsencrypt certificates on a server are valid or due for renewal and restarts the webserver.

Strange output
The text
Cache generated X m ago, cache interval: 24 h, elapsed cache lifespan: X %
shows up in the long output of check plugin column, and the column “Cached agent data” is empty.
See attached screenshot for clarification.

My Service Output was
0 LetsEncrypt-Certs - All certs valid\nCERTNAME (X days valid)

I changed it to include a \n at the end, as I thought that would maybe mark the end of the long output.
Afterwards, it looked like this
0 LetsEncrypt-Certs - All certs valid\nCERTNAME (X days valid)\n

But the Cached-Text still shows up in the Long output of the service.
When clicking on the “Hamburger-Menu” next to the service, what would be expected is the info about the check being cached.
This service is based on cached agent data and cannot be rescheduled. Cache generated X m ago, cache interval: X m, elapsed cache lifespan: X%
This does not show up on the local check because checkmk seems to miss the information about the check being cached.

There is a folder for each server with the check plugin found in:
/omd/sites/SITENAME/tmp/check_mk/cache
When I grep through this cache with grep -i letsencrypt it shows
cached(1612271295,86400) 0 LetsEncrypt-Certs - All certs valid\nCERTNAME (69 days valid)\n
I also tried executing check_mk_caching_agent | grep -i letsencrypt on the server with letsencrypt and this also shows the cached output.

So I guess the caching is working correctly but the multiline output does not?
But when looking at the service (or searching for it via quicksearch) the “Last Checked” column is never reaching 24h.
I don’t really know if the caching is working or not because these different pieces of information lead me to different conclusions.

This is the first local check I wrote with cached agent data, did I miss something?

Thank you for taking the time to read and help.

Info:
CheckMK Enterprise 1.6.0p19 on Ubuntu 18.04.5 LTS
Monitored Servers with LetsEncrypt are (mostly) on WAN, a few or on the same network as the CheckMK Server.

Greetings,
Pixelpoint

Hi,
I would like to remove all \n in service output.I’m not sure if \n in message text has side problems.

Cheers,
Christian

Hello ChristianM,

thank you for taking the time to help me.

I have now removed every \\n from the output.
The “Cache generated …” text now shows up in the short service output instead of the long service output.
See screenshot for clarification.

I found out that the caching mechanism (only execute every 24h) seems to work, even though the text is found in the wrong column.
When I changed the Check it wouldn’t refresh until I removed it from the folder ‘86400’ (which is 24 hours in seconds).

For now I have placed it in a folder ‘3600’ (60 minutes cache interval) on a single machine to make testing easier.

Greetings,
Pixelpoint

I don’t really like to bump without new information, but I can’t figure out what’s wrong here.

Anybody else have an idea?

We had here Windows local check cached suffix
also a longer discussion to this problem. I think i can describe why you cannot remove this suffix in the output.

A normal check you have the header line line <<<my_check>>> if your check is cached then the cache time is included inside the header. With local checks you cannot include this information inside the header it must be inside the check line itself.

Thank you for your answer.
So it seems like there is no way of removing the “cache generated X ago” text from a local check.

As everything is working as expected and it’s only a cosmetic problem, I will close this thread and mark it as solved.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.