Page 1 of 2

check_http with regex

Posted: Wed Nov 18, 2015 9:21 am
by haile711
Hello everyone,

I am trying to do a web service check with ./check_http

Code: Select all

[root@esu4v247 libexec]# ./check_http -H x.x.x.x -p 8080 -u /apollo/info?section=REPLICATION --regex='("status":\s"SUCCESS",|<string>\[\]</string>)'
HTTP OK: HTTP/1.1 200 OK - 1501492 bytes in 0.728 second response time |time=0.727532s;;;0.000000 size=1501492B;;;0
But from the GUI I have the same command and options but doesn't work. Am I doing something wrong, please help me take a look. Thanks!!

Re: check_http with regex

Posted: Wed Nov 18, 2015 10:32 am
by tmcdonald
Using the Test Check Command button is not always accurate for 2 reasons:

1.) Being a PHP page, some characters will be interpreted as control characters (such as the $) and can mess up results.
2.) The command is run as apache, and you are running it as root in your testing. Not usually a problem but there are some plugins that definitely need to be run as nagios.

My advice would be to save the config however you have it and let it run naturally. Check the results there (you can do a forced immediate check if you'd like) and see what it comes up with.

Re: check_http with regex

Posted: Wed Nov 18, 2015 11:07 am
by haile711
hey tmcdonald,
I'll tried that and update. I got "Could Not Compile Regular Expression"

Re: check_http with regex

Posted: Wed Nov 18, 2015 2:25 pm
by rkennedy
Can you try encasing your -u and --regex in double quotes to see if that fixes it?

Re: check_http with regex

Posted: Wed Nov 18, 2015 3:21 pm
by haile711
the same error rkennedy

Re: check_http with regex

Posted: Wed Nov 18, 2015 3:50 pm
by rkennedy
Can you verify the version of your check_http?

/usr/local/nagios/libexec/check_http --version

Re: check_http with regex

Posted: Wed Nov 18, 2015 3:59 pm
by haile711
Here is the output of the version check

Code: Select all

./check_http --version
check_http v2.0.3 (nagios-plugins 2.0.3)

Re: check_http with regex

Posted: Thu Nov 19, 2015 11:28 am
by haile711
Any other suggestions guys? Still stuck on this issue :(

Re: check_http with regex

Posted: Thu Nov 19, 2015 2:18 pm
by lmiltchev
From the Nagios XI web UI, click on "Service Detail", go to the service in question, click on "Configure"->"Re-configure this service" and compare the command that is listed there to the actual command that you run from the CLI (that works). Is it different? Does it work if you modify it to look like the "working" command, and scheduled a forced immediate check? Have you tried using double quotes instead of """ in your command?

Re: check_http with regex

Posted: Thu Nov 19, 2015 3:55 pm
by haile711
hey lmiltchev,
I have tried you suggestion also, but the result is still the same. As you can see in the picture it's the same command use for the CLI. And I've also tried with double quotes too

Code: Select all

./check_http -H <hostname> -p 8080 -u /apollo/info?section=REPLICATION --regex='("status":\s"SUCCESS",|<string>\[\]<tring>)'
HTTP OK: HTTP/1.1 200 OK - 1517811 bytes in 1.262 second response time |time=1.262071s;;;0.000000 size=1517811B;;;0