check_http capturing or verifying certain property in JSON http response

Shijith Thomas shijiththomas2 at gmail.com
Mon Oct 22 15:47:36 CEST 2018


Hello Team,

I'm using check_http plugin for nagios alerting. Till now, i was using the
http status code to raise the alerts.
but recently, i was asked to verify some json http response along with the
http status code where i need to modify my nrpe.cfg file.

check_http -H xxxxx.xxx -S -k 'Host: xxxx.xxx' -k 'Test: Test' -p 443 -j
> POST -T 'application/x-www-form-urlencoded' -P 'name:xyz' -a 'xyz123:
> 123xyz' -u '/a/b/c?Redirect_URL=https://www.google.com/' -e 'HTTP/1.1 200
> OK' -f follow -l -r 'operator:t-mobile'




Here the issue i face is, i am able to detect the status code, but i am not
able to match the regex pattern which i get in http response(JSON)

Sample response suing the curl is :

{

  "a": 12332423452,

  "response": {

    "test": "test1",

    "abc": "abc",

    "operator": "t-mobile",

    "country": "india",

    "currency": "Rupee",

  },

  "id":
> "419E2BD429C1C8E7459911268513C9B5EE3C2AD0E4BE5C528952D6A89DE8D6E2C6623494ADA60C1AAF0462C30CB71874D86D1CFEBEBE26E59DA9654B5ABC9E0916CCD5D88097163AC9ED87B43E00549A86C818700C5B3E561CF0AB9ADC0AB7FA9C072175B4495034CF7F3313CA8D154DA086F9B86EFF3212"

}




I even tried using the -s flag where we can use expected string, but the id
field in the response will be keep changing, which made me to check for
regex.

*Output: *HTTP CRITICAL: Status line output matched "HTTP/1.1 200 OK" -
> HTTP/1.1 200 OK - pattern not found - 9987 bytes in 0.938 second response
> time |time=0.938158s;;;0.000000 size=9987B;;;0


Any suggestion/help would be appreciated. Thanks


-- 
Regards,
Shijith Thomas
Bangalore, Karnataka
India
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/help/attachments/20181022/d780c213/attachment.html>


More information about the Help mailing list