After upgrading to v21.2.68.1492 x64, my custom Powershell XML sensors are starting to give the above error. After logging the result of the script, after the </prtg> a zero suddenly appears, that was not there in the previous PRTG version. The zero is obviously causing the error, but it is not displayed when I run the Powershell script from the commandline. It's almost as if PRTG adds this as a sort of resultcode after running the script...
The following script:
param($paramList) $params = $paramList.Split(" ") if ($params.Count -gt 0) { if ($params.Count -eq 1) { $params += "SAN-CLUSTER" } Import-Module FailoverClusters -ErrorAction Stop $status = Get-ClusterNode $params[0] -cluster $params[1] | ft State -HideTableHeaders | out-string $status = $status -replace "`t|`n|`r| ","" $numState = 0; switch($status) { "Up" { $numState = 1 break } "Down" { $numState = 2 break } "Joining" { $numState = 3 break } "Paused" { $numState = 4 break } } $xml_txt = @" <?xml version=`"1.0`" encoding=`"UTF-8`" ?> <prtg> <result> <channel>Clusternode State</channel> <value>$numState</value> </result> </prtg> "@ [Console]::WriteLine($xml_txt) }
returns the following output:
<?xml version="1.0" encoding="UTF-8" ?>
<prtg>
<result>
<channel>Clusternode State</channel>
<value>1</value>
</result>
</prtg>
and there is no extra zero after </prtg>
The log result from PRTG gives the following output:
<?xml version="1.0" encoding="UTF-8" ?>
<prtg>
<result>
<channel>Clusternode State</channel>
<value>1</value>
</result>
</prtg>
0
containing the extra zero
Is this a bug in the latest version?
Add comment