check_http string not found issue

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Elcom
Posts: 15
Joined: Wed Jul 15, 2020 3:15 am

check_http string not found issue

Post by Elcom »

Hello, I am having issues getting the string check to work on my sites, I am using Nagios XI version 5.7.2 and trying to use check_http as detailed below


My site www.blahblahblah.com redirects to https://www.blahblahblah.com/xx/yy/register.asp

$USER1$/check_http -H $ARG1$ $ARG2$
$ARG1$
blahblahblah.com
$ARG2$
-s "stringiamtesting" -f ok -u /xx/register.asp?f5=true -S --sni -p 443

When I run the test url on nagios xi
/usr/local/nagios/libexec/check_http -H www.blahblahblah.com -s "stringiamtesting" -f ok -u /xx/register.asp?f5=true -S --sni -p 443

I receive the error below
HTTP CRITICAL: HTTP/1.1 404 Not Found - string 'stringiamtesting' not found on 'https://www.blahblahblah.com/xx/yy/regi ... p\?f5=true' - 1503 bytes in 0.013 second response time |time=0.012899s;;;0.000000 size=1503B;;;0

When I run the same command directly on the server via ssh it returns an http 200 ok both as the nagios user and as root as below
HTTP OK: HTTP/1.1 200 OK - 8908 bytes in 0.025 second response time |time=0.025099s;;;0.000000 size=8908B;;;0
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: check_http string not found issue

Post by benjaminsmith »

Hi,

I believe there are some special characters in the string that are not getting passed as desired. This is likely due to sricter security requirements in the Nagios XI PHP scirpts.

Try wrapping the string single quotes instead of double, and test it again. For example,

Code: Select all

/usr/local/nagios/libexec/check_http -H www.blahblahblah.com -s 'stringiamtesting' -f ok -u /xx/register.asp?f5=true -S --sni -p 443
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Elcom
Posts: 15
Joined: Wed Jul 15, 2020 3:15 am

Re: check_http string not found issue

Post by Elcom »

Hi Benjamin, thank you for your reply but unfortunately I still receive the same error using single quotes instead of double quotes
Elcom
Posts: 15
Joined: Wed Jul 15, 2020 3:15 am

Re: check_http string not found issue

Post by Elcom »

Also looking around the forum the fact I am seeing HTTP CRITICAL: HTTP/1.1 404 does this mean the http critical is for the string it does not see and the http/1.1 404 is because it is not seeing the webpage? If so I guess as it does not see the page it will never see the string.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: check_http string not found issue

Post by benjaminsmith »

Hi @Elcom,

I know this not working when you run the test URL in the CCM, but how about the actual check results, are they failing?

Can post a screenshot of the check command from the CCM so we can review how the arguments are being passed?
check-http.png
Also, try wrapping the URL argument in single quotes in case that is getting passed incorrectly via th GUI.

Code: Select all

/usr/local/nagios/libexec/check_http -H www.blahblahblah.com -s "stringiamtesting" -f ok -u '/xx/register.asp?f5=true' -S --sni -p 443
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Elcom
Posts: 15
Joined: Wed Jul 15, 2020 3:15 am

Re: check_http string not found issue

Post by Elcom »

Hi Benjamin,
I have attached a screenshot of the check command from CCM and have tried wrapping the URL in single quotes to no avail.

I am unsure of your question "how about the actual check results, are they failing?" As when I run the command on the command line it returns HTTP OK: HTTP/1.1 200 OK as I had said previously.

Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_http string not found issue

Post by lmiltchev »

I have attached a screenshot of the check command from CCM and have tried wrapping the URL in single quotes to no avail.
Using single quotes should work. Don't test it by clicking on the "Run Check Command" button under the CCM as the CCM seems to be escaping the question mark (\?), which causes the check to fail.

Go to:

Home > Service Status > <your service>, click on Force an immediate check under the Quick Actions section, and review the output.

Is your check working now?
I am unsure of your question "how about the actual check results, are they failing?" As when I run the command on the command line it returns HTTP OK: HTTP/1.1 200 OK as I had said previously.
See the instructions above.

In addition to this, you can try using "-f follow" instead of "-f ok" since your site (www.blahblahblah.com) redirects to https://www.blahblahblah.com/xx/yy/register.asp. I can't test this in house, but I believe you should be using "follow".

Let us know if this helped. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Elcom
Posts: 15
Joined: Wed Jul 15, 2020 3:15 am

Re: check_http string not found issue

Post by Elcom »

Hi Imiltchev,
Many thanks, when I run the force immediate check (Home > Service Status > <your service>, click on Force an immediate check under the Quick Actions) as you suggest this does indeed work, when I try and use the -f follow this still errors.

Is there a way to stop CCM escaping the question mark and causing the test to fail?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: check_http string not found issue

Post by lmiltchev »

Many thanks, when I run the force immediate check (Home > Service Status > <your service>, click on Force an immediate check under the Quick Actions) as you suggest this does indeed work, when I try and use the -f follow this still errors.
Leave the "working" command "as is" then. Don't change it. As long as it works when you click on "Force an immediate check", your check will work just fine.
Is there a way to stop CCM escaping the question mark and causing the test to fail?
Testing in the CCM was never meant to be a replacement of the testing from the command line. It is placed there for convenience. It works in the majority of the cases, but sometimes it fails. Some of the escaping is done for "security reasons", and it won't go away. I hope this makes sense.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked