Jannos-443 / PRTG-VMware-Snapshot

PRTG VMware Snapshot Monitoring
MIT License
13 stars 2 forks source link

XML: Junk after document element </prtg> -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231) #5

Closed Giles-McNamara closed 2 years ago

Giles-McNamara commented 2 years ago

Hi Jannos-443,

I am getting the following error reported from PRTG when using this script:

XML: Junk after document element -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)

The parameters being passed to the sensor are as follows:

-ViServer 'vc.domain.com' -User 'user' -Password 'password'

I have setup the sensor as per the documentation, I have also installed the required PowerShell modules on the Probe Server. If I review the sensors logs I can see the following:

No Snapshots older 24 hours or greater 10GB Total Snapshots 0 Count Snapshot Error 0 Count 1 0 Snapshot Warning 0 Count 1 0

0

If I fill in the parameters directly in the script and run the PowerShell directly from the Probe, I get the below:

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VMware-Snapshot.ps1

Name Port User


vc.domain.com 443 domain\user

No Snapshots older 24 hours or greater 10GB Total Snapshots 0 Count Snapshot Error 0 Count 1 0 Snapshot Warning 0 Count 1 0

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>

Any ideas would be greatly appreciated!

Jannos-443 commented 2 years ago

Hey Giles,

please try the new version, I hope this will fix your problem.

Giles-McNamara commented 2 years ago

Thanks, but unfortunately I have recreated the sensor using the new code and sadly the same problem still persists. The output is still:

No Snapshots older 24 hours or greater 10GB Total Snapshots 0 Count Snapshot Error 0 Count 1 0 Snapshot Warning 0 Count 1 0

0

Yet in PRTG the sensor returns the error:

XML: Junk after document element -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)

Giles-McNamara commented 2 years ago

I have also just tried your PRTG-VMware-Diskspace sensor and I get exactly the same error with that. Does anything else need to be changed in the attached? Sensor Settings

Jannos-443 commented 2 years ago

i know that some other people also got this problem but i really don´t know why.

Could you try to replace the "$xmlOutput" at the end of the Script with this:

  1. Try:

Write-Output $xmlOutput

  1. Try: "
    
    try
    {
    #https://kb.paessler.com/en/topic/64817-how-can-i-show-special-characters-with-exe-script-sensors
    }

catch { $xmlOutput }

Jannos-443 commented 2 years ago

please also try to set the powershell execution policy to unrestricted (64bit and 32bit Powershell) Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Giles-McNamara commented 2 years ago

Sadly the error still persists. I am using PRTG Hosted Monitor, but that shouldn't make any difference. I will log a ticket with PRTG and see what they say, all three of the VMware scrips (Alerts, Disk Space and Snapshots) work fine. The issue is across all three with PRTG displaying the results.

Happy to try any other suggestions, else will keep you posted on what they say.

Jannos-443 commented 2 years ago

Any news here? :) ?

Giles-McNamara commented 2 years ago

Paessler support are still reviewing the case, no new yet.

Giles-McNamara commented 2 years ago

It looks like it might be be an issue with using the hosted version of PRTG.

"We are seeing this issue with other customers as well, I will contact our developers to see if we can get more information about this."

Their findings were:

"The issue seems to be that for some reason, there is content at the end of the XML, a "0". The xml has to be clear at the end."

Will keep you posted.

Giles-McNamara commented 2 years ago

Good news! I believe the issue related to the fact I am using their hosted product, opposed to the self managed product. The issue was fixed after disabling the following:

PowerShell Security Enhancement under "Setup | System Administration | Monitoring":

Jannos-443 commented 2 years ago

@Giles-McNamara all VMware scripts should now work with "Powershell Security Enhancement". (The latest scripts)