What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Checking a JSON result

Votes:

1

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).

comapre json string

Created on Jan 27, 2016 9:21:49 AM



2 Replies

Votes:

0

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.

Created on Jan 27, 2016 11:03:37 AM



Votes:

0

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:

Created on Oct 31, 2019 2:07:20 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.