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?


Article Comments

Attention: This article is a record of a conversation with the Paessler support team. The information in this conversation is not updated to preserve the historical record. As a result, some of the information or recommendations in this conversation might be out of date.

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


May, 2022 - Permalink