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

customUnit not recognized in JSON exe/script advanced

Votes:

0

I've modified the sample Demo Batchfile - Returns static values in four channels.bat to return a JSON result, instead of the original XML, but respecting all the tags names.

The resulting modified file is this one:

@echo off
REM Sample Exe/Script Advanced sensor        
REM Returns four sensor channels with static values to standard OUT
REM Predefines limits for one channel
REM < and > must be escaped in command line scripts

echo { "prtg": {
echo    "result": [
echo      {
echo        "channel": "Demo Minimum Example",
echo        "value": 3
echo      },
echo      {
echo        "channel": "Demo Disk Free",
echo        "unit": "Percent",
echo        "mode": "Absolute",
echo        "showChart": 1,
echo        "showTable": 1,
echo        "warning": 0,
echo        "float": 1,
echo        "value": 38.4487,
echo        "LimitMaxError": 80,
echo        "LimitMaxWarning": 37,
echo        "LimitWarningMsg": "My custom note for warnings",
echo        "LimitErrorMsg": "My custom note for errors",
echo        "LimitMode": 1
echo      },
echo      {
echo        "channel": "Demo Network Speed",
echo        "unit": "SpeedNet",
echo        "volumeSize": "MegaBit",
echo        "mode": "Absolute",
echo        "showChart": 1,
echo        "showTable": 1,
echo        "warning": 0,
echo        "float": 0,
echo        "value": 124487000
echo      },
echo      {
echo        "channel": "Demo Custom",
echo        "unit": "Custom",
echo        "customUnit": "Pieces",
echo        "mode": "Absolute",
echo        "showChart": 1,
echo        "showTable": 1,
echo        "warning": 0,
echo        "float": 0,
echo        "value": 855
echo      }
echo    ],
echo    "text": "Demo values. OS: %OS%"
echo   }
echo }

When I create the sensor the custom units are ignored. Instead of seeing something like the original XML script:

855 Pieces
38,4487 %

I get

855 #
38,4487 #

Have I missed any detail?

json prtg script sensor

Created on Oct 5, 2018 9:31:09 AM



Best Answer

Accepted Answer

Votes:

1

Hi Jorge,

Please try replacing customUnit with CustomUnit and valuelookup with ValueLookup, so basically use them exactly as shown here, then it should work.

It appears those are not case insensitive when using JSON output, we've created also a bugticket for this. Thank you for bringing this to our attention.

Created on Oct 8, 2018 10:51:13 AM by  Erhard Mikulik [Paessler Support]

Last change on Oct 8, 2018 10:53:56 AM by  Erhard Mikulik [Paessler Support]



5 Replies

Votes:

0

Hello Jorge,

From what I've seen so far it's looking fine, it should work, but I stumbled over the same issue when testing this on our end. What you could do, would be simply clicking on the channel and set there the unit manually for now.

I will address this to the devs to look into it, maybe there is an issue with custom units.

Kind regards,

Erhard

Created on Oct 5, 2018 11:20:14 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Thank you. I knew that workaround, but I was including that property, and others, to skip those steps when setting up the sensor.

There are more properties tha don't work if I use JSON, for example, ValueLookup.

I'm developing a custom exe, and I've been able to convert the JSON to XML and all the properties work fine, so it must be a more general problem when handling JSON. Case sensitivity?

Created on Oct 5, 2018 1:33:58 PM



Votes:

0

Hi Jorge,

Yes, it is possible that it is only occurring with JSON, I will add this detail to the ticket, thank you.

Kind regards,

Erhard

Created on Oct 8, 2018 6:33:46 AM by  Erhard Mikulik [Paessler Support]



Accepted Answer

Votes:

1

Hi Jorge,

Please try replacing customUnit with CustomUnit and valuelookup with ValueLookup, so basically use them exactly as shown here, then it should work.

It appears those are not case insensitive when using JSON output, we've created also a bugticket for this. Thank you for bringing this to our attention.

Created on Oct 8, 2018 10:51:13 AM by  Erhard Mikulik [Paessler Support]

Last change on Oct 8, 2018 10:53:56 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Hello Jorge,

I just wanted to follow up on this. With PRTG 19.1.48.2891, the fix coming from the bugticket I've mentioned was implemented. If not already done, I would ask you to install the update as soon as possible. In addition to the bug fixing, additional improvements have been made.

More details can be found at here. Most of the changes can be found in version 19.1.48.2868 of February 2nd 2019.

If you have any further questions, please let me know!

Kind regards,

Erhard

Created on Feb 20, 2019 9:56:41 AM by  Erhard Mikulik [Paessler 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.