How can we monitor special character using check_http

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
sgoffar
Posts: 122
Joined: Wed Sep 21, 2016 9:30 am

How can we monitor special character using check_http

Post by sgoffar »

Hi Team,

For below website we want to monitor the keyword "Status":"1". We are using check_http plugin. i have checked and found that able to monitor only Status but not

"Status":"1".

Can you please help on that.

https://retailws.lsapps.net/us/4.1/Back ... user=44208

o/p on google chrome:

{"Status":"1","ProductCode":"185110007","UPC":"052176995710","ShortName":"511 SLIM BLUE FLAME","Size":"33W x 32L","UnitPrice":"$69.50","PromoDesc":"","PromoPrice":"","ErrorCode":"","ErrorDesc":""}
You do not have the required permissions to view the files attached to this post.
Regards,
Sk Abdul Goffar
Nagios Version:Nagios XI 5.4.8
OS:CentOS release 6.5
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How can we monitor special character using check_http

Post by mcapra »

The -s argument should work. From:
https://nagios-plugins.org/doc/man/check_http.html

Code: Select all

     -s, --string=STRING
        String to expect in the content
In action:

Code: Select all

[root@nagios ~]# /usr/local/nagios/libexec/check_http -H projects.mcapra.com -u '/test.html' -s '"Status":"1"' -v
GET /test.html HTTP/1.1
User-Agent: check_http/v2.2.1.6.g4103.dirty (nagios-plugins 2.2.1)
Connection: close
Host: projects.mcapra.com
Accept: */*


http://projects.mcapra.com:80/test.html is 616 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Date: Tue, 12 Sep 2017 18:09:01 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: __cfduid=d27f3f6eed699bea853420eab0d6490b71505239740; expires=Wed, 12-Sep-18 18:09:00 GMT; path=/; domain=.mcapra.com; HttpOnly
Last-Modified: Tue, 12 Sep 2017 17:58:46 GMT
Accept-Ranges: bytes
Server: cloudflare-nginx
CF-RAY: 39d4d0bb82fe2597-ORD
**** CONTENT ****
{"Status":"1","ProductCode":"185110007","UPC":"052176995710","ShortName":"511 SLIM BLUE FLAME","Size":"33W x 32L","UnitPrice":"$69.50","PromoDesc":"","PromoPrice":"","ErrorCode":"","ErrorDesc":""}

HTTP OK: HTTP/1.1 200 OK - 616 bytes in 0.800 second response time |time=0.799842s;;;0.000000 size=616B;;;0
[root@nagios ~]# /usr/local/nagios/libexec/check_http -H projects.mcapra.com -u '/fail.html' -s '"Status":"1"' -v
GET /fail.html HTTP/1.1
User-Agent: check_http/v2.2.1.6.g4103.dirty (nagios-plugins 2.2.1)
Connection: close
Host: projects.mcapra.com
Accept: */*


http://projects.mcapra.com:80/fail.html is 616 characters
STATUS: HTTP/1.1 200 OK
**** HEADER ****
Date: Tue, 12 Sep 2017 18:09:08 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: __cfduid=ddad7d2774279faa1ab997dd0dd36d7971505239747; expires=Wed, 12-Sep-18 18:09:07 GMT; path=/; domain=.mcapra.com; HttpOnly
Last-Modified: Tue, 12 Sep 2017 17:59:35 GMT
Accept-Ranges: bytes
Server: cloudflare-nginx
CF-RAY: 39d4d0e8b6da5594-ORD
**** CONTENT ****
{"Status":"0","ProductCode":"185110007","UPC":"052176995710","ShortName":"511 SLIM BLUE FLAME","Size":"33W x 32L","UnitPrice":"$69.50","PromoDesc":"","PromoPrice":"","ErrorCode":"","ErrorDesc":""}

HTTP CRITICAL: HTTP/1.1 200 OK - string '"Status":"1"' not found on 'http://projects.mcapra.com:80/fail.html' - 616 bytes in 0.947 second response time |time=0.947252s;;;0.000000 size=616B;;;0
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: How can we monitor special character using check_http

Post by dwhitfield »

Thanks for the assist @mcapra!
sgoffar
Posts: 122
Joined: Wed Sep 21, 2016 9:30 am

Re: How can we monitor special character using check_http

Post by sgoffar »

Can you please type the command . I am still getting error.

~]$ /usr/local/nagios/libexec/check_http -H retailws.lsapps.net -s '"Status":"1"' -f ok -I 172.26.227.18 -u "/us/4.1/BackOffice_Mobility/GetProductPrice.svc/ProductPrice" -S -p 443 HTTP CRITICAL: HTTP/1.1 200 OK - string '"Status":"1"' not found on 'https://retailws.lsapps.net:443/us/4.1/ ... oductPrice' - 595 bytes in 0.030 second response time |time=0.029794s;;;0.000000 size=595B;;;0
Regards,
Sk Abdul Goffar
Nagios Version:Nagios XI 5.4.8
OS:CentOS release 6.5
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How can we monitor special character using check_http

Post by mcapra »

Erm, sure:

Code: Select all

/usr/local/nagios/libexec/check_http -H projects.mcapra.com -u '/test.html' -s '"Status":"1"' -v
Can you execute your check command with the -v flag and verify that "Status":"1" is contained in the response body received by check_http? There's a good chance that check_http is hitting something unexpected.

Like so:

Code: Select all

/usr/local/nagios/libexec/check_http -H retailws.lsapps.net -s '"Status":"1"' -f ok -I 172.26.227.18 -u "/us/4.1/BackOffice_Mobility/GetProductPrice.svc/ProductPrice" -S -p 443 -v
It might also be helpful to know which version of check_http you are using:

Code: Select all

/usr/local/nagios/libexec/check_http -V
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: How can we monitor special character using check_http

Post by dwhitfield »

sgoffar wrote:Can you please type the command
We aren't able to test your URL because we don't have access to it. Perhaps you should try testing on a public URL so that we can see if the issue is with your environment.
sgoffar
Posts: 122
Joined: Wed Sep 21, 2016 9:30 am

Re: How can we monitor special character using check_http

Post by sgoffar »

Please find below the output:
/usr/local/nagios/libexec/check_http -V
check_http v2.0.3 (nagios-plugins 2.0.3)

/usr/local/nagios/libexec/check_http -H retailws.lsapps.net -s '"Status":"1"' -f ok -I 172.26.227.18 -u "/us/4.1/BackOffice_Mobility/GetProductPrice.svc/ProductPrice" -S -p 443 -v

GET /us/4.1/BackOffice_Mobility/GetProductPrice.svc/ProductPrice HTTP/1.1 User-Agent: check_http/v2.0.3 (nagios-plugins 2.0.3) Connection: close Host: retailws.lsapps.net Accept: */* https://172.26.227.18:443/us/4.1/BackOf ... oductPrice is 595 characters STATUS: HTTP/1.1 200 OK **** HEADER **** Cache-Control: private Content-Length: 155 Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/7.5 Set-Cookie: ASP.NET_SessionId=z1f2sdt54muqjy5naligp2hg; path=/; HttpOnly X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: POST,OPTIONS Date: Thu, 14 Sep 2017 10:02:13 GMT Connection: close **** CONTENT **** {"Status":"0","ProductCode":"","UPC":"","ShortName":"","Size":"","UnitPrice":"","PromoDesc":"","PromoPrice":"","ErrorCode":"021","ErrorDesc":"Invalid UPC"} HTTP CRITICAL: HTTP/1.1 200 OK - string '"Status":"1"' not found on 'https://retailws.lsapps.net:443/us/4.1/ ... oductPrice' - 595 bytes in 0.032 second response time |time=0.031760s;;;0.000000 size=595B;;;0
Regards,
Sk Abdul Goffar
Nagios Version:Nagios XI 5.4.8
OS:CentOS release 6.5
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How can we monitor special character using check_http

Post by mcapra »

I'm ... confused? "Status":"1" is not included in that response body. Therefore, the check is returning critical. This is expected behavior since your check is expecting "Status":"1" but not finding it in the response body.

"Status":"0" Is included in the response body though. I've highlighted it:
sgoffar wrote:Please find below the output:
/usr/local/nagios/libexec/check_http -V
check_http v2.0.3 (nagios-plugins 2.0.3)

/usr/local/nagios/libexec/check_http -H retailws.lsapps.net -s '"Status":"1"' -f ok -I 172.26.227.18 -u "/us/4.1/BackOffice_Mobility/GetProductPrice.svc/ProductPrice" -S -p 443 -v

GET /us/4.1/BackOffice_Mobility/GetProductPrice.svc/ProductPrice HTTP/1.1 User-Agent: check_http/v2.0.3 (nagios-plugins 2.0.3) Connection: close Host: retailws.lsapps.net Accept: */* https://172.26.227.18:443/us/4.1/BackOf ... oductPrice is 595 characters STATUS: HTTP/1.1 200 OK **** HEADER **** Cache-Control: private Content-Length: 155 Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/7.5 Set-Cookie: ASP.NET_SessionId=z1f2sdt54muqjy5naligp2hg; path=/; HttpOnly X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Content-Type Access-Control-Allow-Methods: POST,OPTIONS Date: Thu, 14 Sep 2017 10:02:13 GMT Connection: close **** CONTENT **** {"Status":"0","ProductCode":"","UPC":"","ShortName":"","Size":"","UnitPrice":"","PromoDesc":"","PromoPrice":"","ErrorCode":"021","ErrorDesc":"Invalid UPC"} HTTP CRITICAL: HTTP/1.1 200 OK - string '"Status":"1"' not found on 'https://retailws.lsapps.net:443/us/4.1/ ... oductPrice' - 595 bytes in 0.032 second response time |time=0.031760s;;;0.000000 size=595B;;;0
Former Nagios employee
https://www.mcapra.com/
sgoffar
Posts: 122
Joined: Wed Sep 21, 2016 9:30 am

Re: How can we monitor special character using check_http

Post by sgoffar »

Please check the attached screen short you will see the below output.

{"Status":"1","ProductCode":"185110007","UPC":"052176995710","ShortName":"511 SLIM BLUE FLAME","Size":"33W x 32L","UnitPrice":"$69.50","PromoDesc":"","PromoPrice":"","ErrorCode":"","ErrorDesc":""}
You do not have the required permissions to view the files attached to this post.
Regards,
Sk Abdul Goffar
Nagios Version:Nagios XI 5.4.8
OS:CentOS release 6.5
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How can we monitor special character using check_http

Post by mcapra »

The URL included in your screenshot is different from the one you are using in your check_http execution. It seems to include at least one GET variable, UPC.

Please be sure you are accessing the exact URL you wish to monitor when using check_http. Try adding the full URL to your -u argument.
Former Nagios employee
https://www.mcapra.com/
Locked