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?
Article Comments
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?
Oct, 2018 - Permalink
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
Oct, 2018 - Permalink
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.
Oct, 2018 - Permalink
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
Feb, 2019 - Permalink
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
Oct, 2018 - Permalink