I am running a custom EXE/XML sensor and I keep getting the follow error messages:
XML: The returned XML does not match the expected schema. (code: PE233) --
JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)
I run this exact same script from another remote probe and it works correctly.
I have modified the script so that it outputs the XML to a file so I can see where the XML error is. This is what the output looks like:
<?xml version=1.0 encoding=UTF-8 ?>
<prtg>
<result>
<value>2852</value>
<unit>count</unit>
<channel>Number of *.spi Files</channel>
</result>
<result>
<value>7.82</value>
<unit>custom</unit>
<CustomUnit>Hours</CustomUnit>
<float>1</float>
<channel>Newest File Age</channel>
</result>
<text>
OK
</text>
</prtg>
Everything looks fine from this point.
Does PRTG have some place where it stores the output that it is seeing from the sensor error?
Here is the script that is failing on the one remote probe:
Param( [string]$path="\\192.168.1.1\backups", [string]$include= "*.spi" ) $result = "" $size = 0 # Get the list of all files $files = Get-ChildItem -Path $path -include $include -Recurse | Sort-Object LastWriteTime $count = $files.count if ($count -gt 0) { $newestfile = ("{0:N2}" -f (New-Timespan -end (Get-Date) -start ($files)[-1].LastWriteTime).TotalHours).Replace(',','.') $result += @" <result> <value>$count</value> <unit>count</unit> <channel>Number of $($include) Files</channel> </result> <result> <value>$newestfile</value> <unit>custom</unit> <CustomUnit>Hours</CustomUnit> <float>1</float> <channel>Newest File Age</channel> </result> <text> OK </text> "@ } else { $result += @" <error>1</error> <text> No file found matching the filter-parameter "$include" at path "$path" </text> "@ } $result = @" <?xml version=1.0 encoding=UTF-8 ?> <prtg> $result </prtg> "@ #Tee-Object is just for debugging to see what the output looks like# $result | Tee-Object -file "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\test-data-sensor.txt"
Why would this run correctly on some remote probes, but not others?
Add comment