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;


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 -u “my.path/path/status” -s “RUNNING” -S -s “RUNNING”

Thanks in Advance

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.


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 -u “my.path/path/status” -S -s ".(RUNNING).(RUNNING)."
HTTP CRITICAL: HTTP/1.1 200 OK - string '.
(RUNNING).(RUNNING).’ not found on ‘

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.


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:


1 Like

Hi Carsten,

I tried without the quotes and also worked around with wildcards but didn’t work still,

For some reason it works perfectly in the command side but not in Director

Command result
root@server:~# /usr/lib64/nagios/plugins/check_http -H 10.x.x.10 -u “/mypath/online/status” -S -r “.(RUNNING).(RUNNING).*”
HTTP OK: HTTP/1.1 200 OK

Wildcards inside quotes or no quotes doesn’t seem to be working in Director.

Director result
HTTP CRITICAL - No data received from host

Here is my screenshot may be i missed something.


can you check the Inspectlink inside the service please. There you can see what the director renders and try the command on the commandline.


1 Like


I checked the inspect link and this is how the command looks like,

'/usr/lib64/nagios/plugins/check_http' '-I' '10.x.x.10' '-p' '443' '-u' '/mypath/online/status' '-r' '.*(RUNNING).*(RUNNING).*'

I tried it in the commandline and the result was the same;
HTTP CRITICAL - No data received from host

I see your problem, you only set the http_address (-I on commandline) and not the http_vhost (-H on commandline). Set bot in your case to $host.address$ or if different to the same IPs.


1 Like

I did set both and the result is different now,

This time it says;
HTTP CRITICAL: HTTP/1.1 400 Bad Request - pattern not found

in the commandline
root@server:~# ‘/usr/lib64/nagios/plugins/check_http’ ‘-H’ ‘’ ‘-I’ ‘10.x.x.10’ ‘-p’ ‘443’ ‘-u’ ‘/mypath/online/status’ ‘-r’ ‘.(RUNNING).(RUNNING).*’
HTTP CRITICAL: HTTP/1.1 400 Bad Request - pattern not found

Now you can add a -vvv to the command line to see what you get from the webserver.
I think you have to add the bolean var http_ssl to the service. The Director sadly fails to create those wars while importing commands with a set_if in the argument.

1 Like

with -vvv

Every time i add (vars.http_ssl = true) to the services.conf and i restart icinga2 the settings disappears;
May be am adding in a wrong place, Please check the screenshot.
Screenshot 2020-03-31 at 18.35.41

If you use Director you should never edit config files manulay that are created by director. Add the variable to the command and the service with director and it should stay there.
Here is how my template looks like

And the service created with director

As you can see i use only http_ssl and http_sni (needed for my webserver).
Hope it helps you to get your service working.

1 Like

These are the only http fields i have in the options under commands>fields.
Screenshot 2020-04-01 at 11.07.55
I can’t see http_ssl and http_sni in a dropdown

Thats a bug from director, director cant automaticly import arguemnts/fields that are bolean.
Just add them manualy and add them to the command or at the service template.

Am adding a new service template as below

Any idea how my check command should look like ?

You need to create the variables in director first.

then you can add them as fields in the service template.

1 Like