What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

EXEXML Sensor Giving PE233 Error invalid XML Schema

Votes:

0

Your Vote:

Up

Down

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?

customsensor prtg xml

Created on Mar 1, 2019 2:31:21 PM by  jmasse18 (0) 1



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

Hi there,

Please note that we cannot provide support for customization or scripting. The script needs to be located on the corresponding remote probe. In order to get the sensor results, please enable "Write result to disk" in the sensor's "Settings" tab. With the next scan it will write one or several result-files into "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)" of your PRTG server (or on the Remote Probe if applicable). All files have the sensor's numeric ID in their filenames. The sensor ID can be found on the sensor's "Overview" tab.


Kind regards,
Birk Guttmann, Tech Support Team

Created on Mar 5, 2019 11:05:13 AM by  Birk Guttmann [Paessler Support]



4 Replies

Votes:

0

Your Vote:

Up

Down

I also noticed that the scripts are not generating the text file what they are being scanned by PRTG. Would this be a good indication that the scripts are not running?

Created on Mar 1, 2019 3:51:22 PM by  jmasse18 (0) 1



Accepted Answer

Votes:

0

Your Vote:

Up

Down

Hi there,

Please note that we cannot provide support for customization or scripting. The script needs to be located on the corresponding remote probe. In order to get the sensor results, please enable "Write result to disk" in the sensor's "Settings" tab. With the next scan it will write one or several result-files into "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)" of your PRTG server (or on the Remote Probe if applicable). All files have the sensor's numeric ID in their filenames. The sensor ID can be found on the sensor's "Overview" tab.


Kind regards,
Birk Guttmann, Tech Support Team

Created on Mar 5, 2019 11:05:13 AM by  Birk Guttmann [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Perfect! That is exactly what I was looking for for logging purposes. I was able to determine that the XML was correct, but it was actually a server permission setting. Thanks for the reply.

Created on Mar 5, 2019 2:28:40 PM by  jmasse18 (0) 1



Votes:

1

Your Vote:

Up

Down

Hi Jmasse,

I would suggest to start with removing this line:

<?xml version=1.0 encoding=UTF-8 ?>

Then you have a TEXT-Tag in the output that says OK - well - PRTG will use OK anyways if the limits aren't reached. Kind of overhead respective not necessary. Of course, in a error-state you write something else, so eventually there is might matter.

Did not really test you script - but the XML tag might be your primary issues - especially since PRTG is complaining about the output format and that it isn't even sure if it is JSON or XML after all.

  • Remove the XML tag
  • Remove the @ indicators before the string inputs - I don't see a real reason that you need them - but shouldn't be an issue either
  • add the WriteXMLToScreen function
Function WriteXmlToScreen ([xml]$xml) #just to make it clean XML code...
{
	$StringWriter = New-Object System.IO.StringWriter;
	$XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
	$XmlWriter.Formatting = "indented";
	$xml.WriteTo($XmlWriter);
	$XmlWriter.Flush();
	$StringWriter.Flush();
	Write-Output $StringWriter.ToString();
}

The function above should be somewhere in your script - before you output your $result - I actually would comment the following line out $result | Tee-Object -file "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\test-data-sensor.txt" and replace it with the this

Function WriteXmlToScreen ([xml]$xml) #just to make it clean XML code...
{
	$StringWriter = New-Object System.IO.StringWriter;
	$XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
	$XmlWriter.Formatting = "indented";
	$xml.WriteTo($XmlWriter);
	$XmlWriter.Flush();
	$StringWriter.Flush();
	Write-Output $StringWriter.ToString();
}
WriteXmlToScreen $result

This will parse the $result string through a XML Text Writer and kind of make sure it is accurate before it writes it to the screen...

So - having said all of that - I once wrote a script in WSH/VBscript that actually does something very similar - see either one of the following links:

All you need to look at is the SQLBackupDestinationCheck.vbs script - you could simply use it with those parameters

1 "spi" "\\192.168.1.1\backups"

But I leave this up to you...

Hope I could point you in the right direction, though.

Regards

Florian Rossmark

www.it-admins.com

Created on Mar 5, 2019 2:56:16 PM by  Florian Rossmark (4,334) 4 2



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.