Page 1 of 1

check_http string not found issue

Posted: Thu Sep 03, 2020 8:06 am
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

Re: check_http string not found issue

Posted: Thu Sep 03, 2020 5:14 pm
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

Re: check_http string not found issue

Posted: Fri Sep 04, 2020 1:29 am
by Elcom
Hi Benjamin, thank you for your reply but unfortunately I still receive the same error using single quotes instead of double quotes

Re: check_http string not found issue

Posted: Fri Sep 04, 2020 2:01 am
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.

Re: check_http string not found issue

Posted: Fri Sep 04, 2020 4:56 pm
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

Re: check_http string not found issue

Posted: Mon Sep 07, 2020 1:59 am
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

Re: check_http string not found issue

Posted: Tue Sep 08, 2020 3:44 pm
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!

Re: check_http string not found issue

Posted: Wed Sep 09, 2020 2:10 am
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?

Re: check_http string not found issue

Posted: Wed Sep 09, 2020 10:13 am
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.