check_http with regex

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

check_http with regex

Post 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!!
You do not have the required permissions to view the files attached to this post.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_http with regex

Post 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.
Former Nagios employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: check_http with regex

Post by haile711 »

hey tmcdonald,
I'll tried that and update. I got "Could Not Compile Regular Expression"
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_http with regex

Post by rkennedy »

Can you try encasing your -u and --regex in double quotes to see if that fixes it?
Former Nagios Employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: check_http with regex

Post by haile711 »

the same error rkennedy
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_http with regex

Post by rkennedy »

Can you verify the version of your check_http?

/usr/local/nagios/libexec/check_http --version
Former Nagios Employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: check_http with regex

Post 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)
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: check_http with regex

Post by haile711 »

Any other suggestions guys? Still stuck on this issue :(
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_http with regex

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: check_http with regex

Post 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
You do not have the required permissions to view the files attached to this post.
Locked