New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


REST JSONPath

Votes:

0

Your Vote:

Up

Down

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!

json jsonpath rest

Created on Apr 28, 2018 5:42:57 PM by  bsabramov (0) 1

Last change on Apr 30, 2018 5:18:11 AM by  Luciano Lingnau [Paessler Support]



4 Replies

Votes:

0

Your Vote:

Up

Down

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.

Created on Apr 30, 2018 8:41:02 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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"
  }
]

Created on May 8, 2018 2:01:56 PM by  bsabramov (0) 1

Last change on May 8, 2018 7:54:56 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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'!"
      }
    ]
  }
}

Created on May 8, 2018 8:07:35 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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"
      }
    ]
  }
}

Created on Mar 21, 2020 8:40:45 PM by  Cucullatus (0)

Last change on Mar 24, 2020 6:09:57 AM by  Andreas Günther [Paessler Support]



Please log in or register to enter your reply.


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.