What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Custom View Sensor from Github returns JSON XML Error

Votes:

0

Hello,
I just added a custom ps-script from Github, but I get an error returned. This is the error in german:

XML: Das zurückgelieferte XML entspricht nicht dem erwarteten Schema. (Code: PE233) -- JSON: Das zurückgelieferte JSON entspricht nicht der erwarteten Struktur (No mapping for the Unicode character exists in the target multi-byte code page). (Code: PE231)

In english:

XML: The returned xml does not match the expected schema. (code: PE233)  -- JSON: The returned JSON does not match the expected structure (No mapping for the Unicode character exists in the target multi-byte code page). (Code: PE231)

Sometimes this error appears: No "result" or "error" in XML response.

What I did:

  • Installed VMware PowerCLI on the Connection Server
  • Unrestricted the Policies
  • Enabled WinRM
  • Installed Powershell 3.0
  • Ran the script in PS ISE, no Error returned!

    Hope you can help me.

    Best regards

custom custom-script-exe custom-sensor error json pe231 pe233 prtg script xml

Created on Jun 15, 2018 8:04:12 AM

Last change on Jun 15, 2018 11:29:51 AM by  Birk Guttmann [Paessler Support]



3 Replies

Votes:

0

Hello Marco,

Thanks for your support inquiry, we appreciate your contact regarding this matter!

Please tell me how you passed the parameters to the script in PRTG. So, we can make sure everything is passed correctly.

The syntax for the parameter field should look like:

-server "servername" -name "loginname" -pw "password"



Kind regards,
Birk Guttmann, Tech Support Team

Created on Jun 15, 2018 11:44:13 AM by  Birk Guttmann [Paessler Support]

Last change on Jun 15, 2018 11:44:50 AM by  Birk Guttmann [Paessler Support]



Votes:

0

Hello Birk,

first, this is the script I use from github:

Description:
Displays the connected/disconnected/Agent unreachable/error VMware View Sessions per Pool

Parameters:
-ComputerName - The name of the computer you want to check for its service
-Username: The username and the domain/computer name that applies to the target hosts
-Password: The password for the given user.

Example execution in powershell:
'Powershell Script - VMWare View - Total View Sessions.ps1' -ComputerName viewconnectionserver-UserName Administrator -Password Password

Example execution in PRTG:
Install View PowerCli on the Vmware View connection server
Copy file to PRTG probe c:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML
Add Sensor EXE/Script Advanced
EXE/Script Advanced Sensor Parameters: -ComputerName viewconnectionserver -Username %windowsuser -Password %windowspassword

WinRM needs to be enabled on the device (https://msdn.microsoft.com/en-us/library/aa384372(v=vs.85).aspx)
Try to connect by hostname not the ip or configure WinRM for HTTPS.

Param(
[string]$ComputerName = "CN",
[string]$UserName = "Administrator",
[string]$Password = "PW"
)

#create credentials 
$SecPassword = ConvertTo-SecureString $Password -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential ($UserName, $secPassword)



$ret = invoke-command -computer $ComputerName -Credential $cred -ScriptBlock {
Add-PSSnapin vmware.view.broker

$Poolids = (Get-Pool).Pool_id



"<prtg>"
ForEach ($Poolid in $Poolids) {

# Collect Desktop Information

$ConnectedAll = (Get-RemoteSession -errorAction SilentlyContinue | Where { $_.state -like "CONNECTED"} | Select state).count
$Connected = (Get-RemoteSession -pool_id $Poolid -errorAction SilentlyContinue | Where { $_.state -like "CONNECTED"} | Select state).count
$Disconnected  = (Get-RemoteSession -pool_id $Poolid -errorAction SilentlyContinue | Where { $_.state -like "DISCONNECTED"} | Select state).count
$Unreachable  = (Get-RemoteSession -pool_id $Poolid -errorAction SilentlyContinue | Where { $_.state -like "Agent unreachable"} | Select state).count
$AgentError  = (Get-RemoteSession -pool_id $Poolid -errorAction SilentlyContinue | Where { $_.state -like "Error"} | Select state).count
$Provisioned = (Get-DesktopVM -pool_id $Poolid).count
$Poolenabled = (Get-Pool -pool_id $Poolid).provisionEnabled

if ($Poolenabled -eq "true") 

{
    $PoolenabledResult = 1
   }
   else {
    
    $PoolenabledResult = 2  
}



#returning PRTG XML data

       "<result>"
       "<channel>Total Connected View sessions</channel>"
       "<value>$ConnectedAll</value>"
       "</result>"
       "<result>"
       "<channel>Pool $Poolid enabled</channel>"
       "<value>$PoolenabledResult</value>"
       "<LimitMode>1</LimitMode>"	
       "<LimitMaxWarning>1</LimitMaxWarning>"
       "</result>"
       "<result>"
       "<channel>Connected sessions on $Poolid</channel>"
       "<value>$Connected</value>"
       "</result>"
       "<result>"
       "<channel>Disconnected sessions on $Poolid</channel>"
       "<value>$Disconnected</value>"
       "</result>"
       "<result>"
       "<channel>Error sessions on $Poolid</channel>"
       "<value>$AgentError</value>"
       "<LimitMode>1</LimitMode>"	
       "<LimitMaxWarning>0</LimitMaxWarning>"
       "</result>"
       "<result>"
       "<channel>Agent unreachable sessions on $Poolid</channel>"
       "<value>$Unreachable</value>"
       "<LimitMode>1</LimitMode>"	
       "<LimitMaxWarning>0</LimitMaxWarning>"
       "</result>"
       "<result>"
       "<channel>Provisioned VMs on $Poolid</channel>"
       "<value>$Provisioned</value>"
       "</result>"
       

 }
 "<text>$ConnectedAll Sessions on all pools</text>"
 "</prtg>"
}  # end script block
$ret

When I edit the string ComputerName, UserName and Password to the original I'd use, then I don't have to use any parameters right? But anyway, still with using this parameter: -ComputerName XY -UserName XY -Password XY - nothing happens, except an error..

Best regards

Created on Jun 18, 2018 5:22:26 AM

Last change on Jun 18, 2018 8:30:41 AM by  Birk Guttmann [Paessler Support]



Votes:

0

Hi Marco,

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. Please send us those results.


Kind regards,
Birk Guttmann, Tech Support Team

Created on Jun 18, 2018 2:36:54 PM by  Birk Guttmann [Paessler Support]




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.