I am checking JSON, I have a set values get returned:
{ "status": { "code": 200, "text": "OK" }, "response": { "authenticated": false, "results": 16 }, "results": { "accounts": "OK", "audioprompts": "OK", "authenticate": "OK", "calls": "OK", "conferences": "OK", "connectors": "OK", "contacts": "OK", "countries": "OK", "diverts": "OK", "documentation": "OK", "numbers": "OK", "queues": "OK", "sip": "OK", "sms": "OK", "status": "OK", "voicemail": "OK" } }
I want to glean values or even just check that it is equal to above.
I am using an "HTTP XML/REST Value" sensor.
I guess the magic, would occur in XML Node (and optional property).
Article Comments
Problem
Fetching a webpage by http-GET. Result is JSON like this:
{ "cows": "ok", "hens": "ok", "lamas": "fail" }
There are no number-values given by the webpage request, only „ok“ or something different (like lamas in this example).
How to solve the problem with PRTG
- Take the PRTG-Sensor "HTTP Advanced"
- Sensorname: livestock-cows
- URL: http://your-rest-server.com/livestock-example.json
- Advanced sensor data | Require Keyword: Set sensor to down status if keyword is missing
- Advanced sensor data | Response must include: "cows":\s"ok"
- Advanced sensor data | Check method: Regular expression
Problem with this solution
You cannot check more complicated json where a string "status": "ok" omits more than one time:
{ "cows": { "number": 10, "status": "ok" }, "hens": { "number": 400, "status": "ok" } }
Hints for research
I found hints to solve the problem here:
- https://helpdesk.paessler.com/en/support/solutions/articles/74664-interpreting-a-json-response-in-http-xml-rest-value-sensor
- https://prtg.zirndorf.de/help/http_advanced_sensor.htm#httpadvanced
Oct, 2019 - Permalink
Hi,
Using the "HTTP XML/REST Value" sensor you can only check on numeric values in your JSON result.
So checking if code=200 or results=16 is no problem.
Checking if accounts=OK will unfortunately not work.
Jan, 2016 - Permalink