Check for the same word/string appearing multiple times in one line

Hi Team,

Is it possible to use check_http to check for the same string or word if it is appearing twice in the same line ?

For example if the url output says;

state":“RUNNING”,“worker_id”:“x.x.x.x:8643”},“tasks”:[{“id”:0,“state”:“RUNNING”,“worker_id”:“x.x.x.x:8643”}

From the above out i want to monitor that word RUNNING appears twice = ok
RUNNING appears once = critical or warning
RUNNING does not appear = critical.

Below is what i tried but am not satisfied with what its doing,

check_http -H my.website -u “my.path/path/status” -s “RUNNING” -S -s “RUNNING”

Thanks in Advance
Charlie

Hi and welcome.

You can use a regex to check it .*(RUNNING).*(RUNNING).*, this would check both of them.
As soon it doesnt match you, the service should go into non ok state.

Regards,
Carsten

1 Like

Thank you so much for the reply Carsten,

Doesn’t seem to be working, I also tried playing around with wildcards but still not working says string not found…

check_http -H my.website -u “my.path/path/status” -S -s ".(RUNNING).(RUNNING)."
HTTP CRITICAL: HTTP/1.1 200 OK - string '.
(RUNNING).(RUNNING).’ not found on ‘https://my.website:443/path

Kind Regards

You have to use the -r switch for regex. see check_http --help

1 Like

-r worked…

Once again thank you for the assistance.

1 Like

Hi Carsten,

This is strange,
For some reason the string works fine via the commands.

However if i try using the same string via Icinga Director, it returns pattern not found.

Could it be the wildcards don’t work in Director, I tried with different wildcards and still dint help.

HTTP CRITICAL: HTTP/1.0 503 Service Unavailable - pattern not found

Please check my screenshot below and see if something is missing.

Thanks
Charlie

Dont use quoutesaround the regex in director

1 Like

Hi Charles,
welcome to the community!

I would like to ask you to mark the answer that solved your issue as the solution, as it helps others find it quicker and tells people that your problem has already been dealt with :slight_smile:

Thanks,
Feu

1 Like