This support forum board is for support questions relating to
Nagios XI , our flagship commercial network monitoring solution.
mindspring
Posts: 117 Joined: Thu Jul 19, 2012 10:24 am
Post
by mindspring » Thu Nov 28, 2019 6:40 am
Hi There,
I am trying to use the check_http plugin to search for a string on a website and if it doesn't find the string, it needs to generate an alert.
The problem I am having is that I am not sure if I can authenticate using the header auth bearer token method. Is this possible to use as I have to get past this auth to search for the string?
Code: Select all
[root]@nagios]/usr/local/nagiosxi/etc/components/webinject] $ /usr/local/nagios/libexec/check_http -H xxxx -R '/health_check/' -p 443 -u 'site/check-big-query-health' -f ok -k --header="Authorization: Bearer xxxxx"
HTTP CRITICAL: HTTP/1.1 400 Bad Request - pattern not found - 325 bytes in 0.041 second response time |time=0.041365s;;;0.000000 size=325B;;;0
I get this error but I am sure it's not making it past the auth even.
Thanks
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Mon Dec 02, 2019 7:38 am
Can you add the -vvv for verbose output to see how far you are getting?
Code: Select all
/usr/local/nagios/libexec/check_http -H xxxx -R '/health_check/' -p 443 -u 'site/check-big-query-health' -f ok --header="Authorization: Bearer xxxxx" -vvv
I did also note you have -p 443 but are not passing the -S flag? is this on purpose? You may also want to try
Code: Select all
/usr/local/nagios/libexec/check_http -H xxxx -R '/health_check/' -p 443 -S -u '/site/check-big-query-health' -f ok --header="Authorization: Bearer xxxxx" -vvv
mindspring
Posts: 117 Joined: Thu Jul 19, 2012 10:24 am
Post
by mindspring » Tue Dec 03, 2019 7:15 am
Thanks, i tried and it comes up with this:
Code: Select all
[root]@cloudnagios ~] $ /usr/local/nagios/libexec/check_http -H xxxxx -R '/health_check/' -p 443 -S -u '/site/check-big-query-health' -f ok -k --header="Authorization: Bearer xxxxx" -vvv
GET /site/check-big-query-health HTTP/1.1
User-Agent: check_http/v2.0.3 (nagios-plugins 2.0.3)
Connection: close
Host: xxxxxx
Accept: */*
--header=Authorization: Bearer xxxxxx
https://xxxxx:443/site/check-big-query-health is 261 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Server: nginx/1.12.2
Date: Tue, 03 Dec 2019 12:13:38 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
X-Powered-By: PHP/7.3.10
**** CONTENT ****
34
{"status":"error","reason":"Invalid authentication"}
0
HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 261 bytes in 0.118 second response time |time=0.118290s;;;0.000000 size=261B;;;0
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Tue Dec 03, 2019 8:31 am
This doesn't look lik eit is getting in there correct
Code: Select all
Host: xxxxxx
Accept: */*
--header=Authorization: Bearer xxxxxx
This possibly could be a bug in version 2.0.3 of the plugin you are using, I tested in on 2.2.1 and it works properly and the header is in there correctly
Code: Select all
/usr/local/nagios/libexec/check_http -H www.nagios.com -p 443 -S --header="Authorization: Bearer xxxxx" -vvv
SSL initialized
GET / HTTP/1.1
User-Agent: check_http/v2.2.1 (nagios-plugins 2.2.1)
Connection: close
Host: www.nagios.com
Accept: */*
Authorization: Bearer xxxxx
https://www.nagios.com:443/ is 131237 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Date: Tue, 03 Dec 2019 13:28:21 GMT
Server: Apache
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=0, no-cache, must-revalidate
X-Mod-Pagespeed: 1.13.35.2-0
Access-Control-Allow-Origin: *
Content-Length: 130937
Connection: close
Content-Type: text/html; charset=UTF-8
...
mindspring
Posts: 117 Joined: Thu Jul 19, 2012 10:24 am
Post
by mindspring » Thu Dec 05, 2019 8:55 am
Thanks, I upgraded to version 2.3 and it now comes up with this:
Code: Select all
[root]@cloudnagios] ~/nagios-plugins-2.3.0] $ /usr/local/nagios/libexec/check_http -H host1 -R '/health_check/' -p 443 -S -u '/site/check-big-query-health' -f ok -k --header="Authorization: Bearer xxxxxx" -vvv
SSL initialized
GET /site/check-big-query-health HTTP/1.1
User-Agent: check_http/v2.3.0 (nagios-plugins 2.3.0)
Connection: close
Host: host1
Accept: */*
--header=Authorization: Bearer xxxxxx
https://host1:443/site/check-big-query-health is 261 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Server: nginx/1.12.2
Date: Thu, 05 Dec 2019 13:53:51 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
X-Powered-By: PHP/7.3.10
**** CONTENT ****
{"status":"error","reason":"Invalid authentication"}
HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 261 bytes in 0.120 second response time |time=0.119776s;;;0.000000 size=261B;;;0
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Dec 05, 2019 9:01 am
You have both the
-k &
--header , you can't have both
it should be
Code: Select all
/usr/local/nagios/libexec/check_http -H host1 -R '/health_check/' -p 443 -S -u '/site/check-big-query-health' -f ok --header="Authorization: Bearer xxxxxx" -vvv