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?
Add comment