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

How do I format my response in a custom Sensor Template?

Votes:

0

Hello everyone, im currently trying to set up a REST custom sensor, which returns a json string. To read the json response I need to configure my REST template. My json response: {"diskusage":"50%","ramusage":"2246","cpuload":"7%","cputemp":"54.04"} My Template right now:

{
   "prtg": {
      "result": [
         {
            "Channel": "ramusage",
	    "CustomUnit": "gb",
	    "Float": 1,
            "Value": $.ramusage
         },
         {
            "Channel": "cputemp",
            "CustomUnit": "°C",
            "Float": 1,
            "Value": $.cputemp
         },
         {
            "Channel": "diskusage",
            "CustomUnit": "%",
            "Value": $.diskusage
         },
	{
	    "Channel": "cpuload",
	    "CustomUnit": "%",
	    "Value": $.cpuload
	 }
      ]
   }
}

Which works perfectly fine for my Integer/ Float values. But for "diskusage" and "cpuload" I get an error. Because value only accept Integers/ Floats but not string.

My Solution would be to cut off the "%" of the 2 values to "convert" it into a Float. But how do I do that? Is there any better way to do this?

api json prtg rest

Created on May 23, 2022 12:11:34 PM

Last change on May 24, 2022 6:21:49 AM by  Felix Wiesneth [Paessler Support]



1 Reply

Votes:

0

Hello Jonas,

Thanks for contacting us.

Unfortunately it is hard to change PRTG here since it is designed to monitor integer values. The only alternative option would be to create a custom script which "translates" the strings into integer values.

Regards,

Miguel Aikens

Created on May 24, 2022 11:50:22 PM by  Miguel Aikens [Paessler Technical Support]




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.