Because i found no needful Example of a PowerShell Example of a PRTG Advanced Custom Sensor and i dislike XML. I worked out an PowerShell Example of a PRTG Advanced Custom Sensor with use of JSON Hope this helps some one else to get a faster start on it.
See also: https://www.paessler.com/manuals/prtg/custom_sensors#advanced_sensors
<# Sample Exe/Script Advanced sensor Returns four sensor channels with static values to standard OUT Predefines limits for one channel See: https://www.paessler.com/manuals/prtg/custom_sensors#advanced_sensors Output can be with the following commands Write-Host $XMLResult or Write-Host $JsonResult Write-Output $XMLResult or Write-Host $JsonResult # or simply return the xml / json text without any command $XMLResult or $JsonResult This Example uses JSON for output at the end #> $XMLResult = @" <prtg> <result> <channel>Demo Minimum Example</channel> <value>3</value> </result> <result> <channel>Demo Disk Free</channel> <unit>Percent</unit> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>1</float> <value>38.4487</value> <LimitMaxError>80</LimitMaxError> <LimitMaxWarning>37</LimitMaxWarning> <LimitWarningMsg>My custom note for warnings</LimitWarningMsg> <LimitErrorMsg>My custom note for errors</LimitErrorMsg> <LimitMode>1</LimitMode> </result> <result> <channel>Demo Network Speed</channel> <unit>SpeedNet</unit> <volumeSize>MegaBit</volumeSize> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>0</float> <value>124487000</value> </result> <result> <channel>Demo Custom</channel> <unit>Custom</unit> <customUnit>Pieces</customUnit> <mode>Absolute</mode> <showChart>1</showChart> <showTable>1</showTable> <warning>0</warning> <float>0</float> <value>855</value> </result> <text>Demo values. OS: $($env:OS)</text> </prtg> "@ $JsonResult = @" { "prtg": { "result": [ { "channel": "Demo Minimum Example", "value": "3" }, { "channel": "Demo Disk Free", "unit": "Percent", "mode": "Absolute", "showChart": "1", "showTable": "1", "warning": "0", "float": "1", "value": "38.4487", "LimitMaxError": "80", "LimitMaxWarning": "37", "LimitWarningMsg": "My custom note for warnings", "LimitErrorMsg": "My custom note for errors", "LimitMode": "1" }, { "channel": "Demo Network Speed", "unit": "SpeedNet", "volumeSize": "MegaBit", "mode": "Absolute", "showChart": "1", "showTable": "1", "warning": "0", "float": "0", "value": "124487000" }, { "channel": "Demo Custom", "unit": "Custom", "customUnit": "Pieces", "mode": "Absolute", "showChart": "1", "showTable": "1", "warning": "0", "float": "0", "value": "855" } ], "text": "Demo values. OS: $($env:OS)" } } "@ $JsonResult
Add comment