Hi all!
I am using REST Custom sensor to get data in JSON format, using JSONPath.
I can't solve two problems:

  1. I need to get the device temperature. I get it in format "60 *C" (without quotes). How to "tell" prtg get only digits from this text, while performing http get and JSONPath?
  2. I need to collect device status info. It is like "On" or "Off". How can I interprete that? I think I need to equate On=0, and Off=1. Or there is better ways? If no, how can I do this using JSONPath?

Thank you very much!


Article Comments

Hi there,

You can find most described in the manual of the rest sensor:
https://www.paessler.com/manuals/prtg/rest_custom_sensor

It would also help if you could post the monitored JSON so I can post the code example for both of your described cases.

Best regards.


Apr, 2018 - Permalink

Hello. Below is my sample json. Form "temperature" I need to collect only digits, because PRTG doesn't accept anything but digits. I need to collect device status too (On, Off, N/a), and to be able to trigger an allert when device status is not "On".

Thank you for your help! Best regards, Boris.

[
  {
    "device1": "On",
    "temperature": "50 *C",
    "alarm": "Cleared"
  },
  {
    "device2": "Off",
    "hostName": "55 *C",
    "alarm": "Cleared"
  },
  {
    "device3": "N/a",
    "hostName": "54 *C",
    "alarm": "Cleared"
  }
]

May, 2018 - Permalink

Hi there,

The check for "on" or not "on" shouldn't be an issue. However checking the temperature will not be possible as there is no option to cut off certain characters or to just use the first 2 chars of a node.

Checking for on or not on could look like this in the template:

{
  "prtg": {
		"text": "Device1 Status - " $.X.[0],
    "result": [
      {
		"channel": "Status",
		"value": lookup($.X.[0], "On"),
		"limitmode": 1,
		"LimitMinError": 0,
		"LimitErrorMsg": "The value for 'status' is not 'On'!"
      }
    ]
  }
}

May, 2018 - Permalink

Apologies for replying to an old thread, however it seems to be the closest to the problem that I face.

I am trying to use the HTTP Push Data Advanced sensor to push JSON data into PRTG. The sensor is receiving data however one of the channels posts the value as text, either 'success' or 'failed'.

How can I change this on import for PRTG to accept? It seems that in the above example of "on" or "not on" it appears that it would be possible by changing the text to binary, 0 or 1?

Any help would be appreciated, thanks in advance!

{
  "prtg": {
    "result": [
      {
		"channel": "Status",
		"value": "Success"
      }
    ]
  }
}

Mar, 2020 - Permalink