Check http search in body

Hi all

I’m quite new to checkmk and am using the check http service to do a healthcheck on a URL I have.

The response contains some json and within it there is a line: “status”: “OK”

I have tried all sorts of different combinations to get this to match but so far have failed.

I have tried it with just a straight string and all sorts of different regex. I can get it to match until I reach the space.

Can anybody help please.

TIA
Daz

Hi Daz and welcome to the forum.

I would assume that this would work (I omitted an endpoint in this example):

The pattern is

"status":\s*"OK"

The \s* means: an arbitrary amount of whitespace (including none). So this will match

"status": "OK"
"status":    "OK"
"status":"OK"
1 Like

Since Checkmk still doesn’t have a check for JSON responses, you might want to consider trying Bastian Kuhn’s check:

And vote for:
https://ideas.checkmk.com/suggestions/302561/add-a-generic-plugin-for-polling-of-json-status-apis

If you wish to continue using check_httpv2 , you can try one of the following:

"status":"OK",
"status":\s*"OK",
"status"\s*:"OK",
"status"\s*:\s*"OK"
"(?i)status.*?:.*?ok"
"status.*?OK"

or simply search only for "OK"

On https://regex101.com/ you can play around and test your regex.

Thank you, that matched perfectly, I had tried \s without the *

1 Like

Thank you, I will look at these.

I did think to check for just the OK and that did worked but I know there will be more complex ones in the future. I will certainly check out the agent_json.