vMarkusK / Advanced-PRTG-Sensors

Collection of my Advanced PRTG Sensors
https://mycloudrevolution.com/
Apache License 2.0
67 stars 29 forks source link

JSON: Das zurückgelieferte JSON entspricht nicht der erwarteten Struktur (Invalid JSON.). (Code: PE231) #10

Closed eren-kemer closed 6 years ago

eren-kemer commented 7 years ago

Hello,

to me it seems like the powershell script is not picking up my parameters. This is how i set it up in PRTG. Is it the correct way to give PSx64.exe the parameters?

-f="PRTG-VeeamBRStats.ps1" -p="-repoCritical 80 -repoWarn 70 -reportmode "Weekly"

As soon as i put in the -p= part, i get this error:

XML: Structural error in xml file, 1 open items. -- JSON: Das zurückgelieferte JSON entspricht nicht der erwarteten Struktur (Invalid JSON.). (Code: PE231)

I also ran the script on the probe manually. This is the output when running the ps1 script in powershell. I have X'ed the private parts.:

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML.\PRTG-Vee
amBRStats.ps1
Starting to Process Connection to backup01 ...
Connecting BRHost...
<prtg>
<result>
<channel>Successful-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Backups</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Idle-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-Replications</channel>
<value>7</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Replications</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Replications</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>TotalBackupRead</channel>
<value>109</value>
<unit>Custom</unit>
<customUnit>GB</customUnit>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>TotalBackupTransfer</channel>
<value>34</value>
<unit>Custom</unit>
<customUnit>GB</customUnit>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>REPO - Cloud repository XXX 01</channel>
<value>100</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - Default Backup Repository</channel>
<value>50</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - QNAP Veeam Backup</channel>
<value>11</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
</prtg>

This is what i get when i try to run the script using PSx64.exe:

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>PSx64.exe -f="
PRTG-VeeamBRStats.ps1"
0:Starting to Process Connection to backup01 ...
Connecting BRHost...
<prtg>
<result>
<channel>Successful-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-Backups</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Backups</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Idle-BackupCopys</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Successful-Replications</channel>
<value>7</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>Warning-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxWarning>0</LimitMaxWarning>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failes-Replications</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Failed-Replications</channel>
<value>0</value>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMaxError>0</LimitMaxError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>Running-Replications</channel>
<value>1</value>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>TotalBackupRead</channel>
<value>109</value>
<unit>Custom</unit>
<customUnit>GB</customUnit>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>TotalBackupTransfer</channel>
<value>34</value>
<unit>Custom</unit>
<customUnit>GB</customUnit>
<showChart>1</showChart>
<showTable>1</showTable>
</result>
<result>
<channel>REPO - Cloud repository XXX 01</channel>
<value>100</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - Default Backup Repository</channel>
<value>50</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
<result>
<channel>REPO - QNAP Veeam Backup</channel>
<value>11</value>
<unit>Percent</unit>
<showChart>1</showChart>
<showTable>1</showTable>
<LimitMinWarning>20</LimitMinWarning>
<LimitMinError>10</LimitMinError>
<LimitMode>1</LimitMode>
</result>
</prtg>

I'll be glad to provide further logs as required.

vMarkusK commented 7 years ago

Hello,

output in CMD an PS looks fine for me. So PRTG should process that. Have you checked the PRTG sensor Log? The default parameter of the Script normally work fine. So you don’t need to use the -p switch only for BRhost or set the default in the ps1 file.

If you want to use all parameters you should try it this way: -f="PRTG-VeeamBRStats.ps1" -p="-repoCritical 80 -repoWarn 70 -reportmode Weekly"

Kind regards, Markus

eren-kemer commented 7 years ago

Hello, thanks for the reply!

the default parameter for BRHost in the script has already been modified by me. This is not appropiate for my use case though, as we don't always have the same name for our B&R Servers. I'd also like to be able to set the warn, critical and reportmode parameters per sensor, like i tried to. i have set my parameter string in the sensor config to this: -f="PRTG-VeeamBRStats.ps1" -p="-repoCritical 80 -repoWarn 70 -reportmode Weekly"

Still getting the same XML structural error.

What i have noticed is.. in your powershell script, you mention that reportmode is a string and should be in quotation marks. What is the definitive answer on this?

.EXAMPLE 
PRTG-VeeamBRStats.ps1 -BRHost veeam01.lan.local -reportmode "Monthly" -repoCritical 80 -repoWarn 70 -Debug

To me it seems like the script does not take my parameters. When i change the default host in the script to the right host, it works:

[string] $BRHost = "backup01",

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>PSx64.exe -f= PRTG-VeeamBRStats.ps1" 0:Starting to Process Connection to backup01 ... Connecting BRHost...

When i keep it to

[string] $BRHost = "blabla01",

and try giving it the BRHost as parameter, it doesn't work:

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML>PSx64.exe -f="PRTG-VeeamBRStats.ps1" -p="BRHost backup01"
0: Failed to connect to Veeam Backup & Replication server

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

What am i doing wrong here? How can i check whether i'm doing something wrong?

vMarkusK commented 7 years ago

Have you tried the connection via Veeam Console from this server?

vMarkusK commented 6 years ago

Hello @eren-kemer,

Is the problem solved?

eren-kemer commented 6 years ago

Please give me a few days to check with latest commits included.

eren-kemer commented 6 years ago

I have now found the issue with the way i did it. I have to supply the parameters to Psx64.exe like this: -f="PRTG-VeeamBRStats2.ps1" -p="localhost",""Monthly"", "80", "70" This way, i get correct output, even with parameters in the sensor.

You might want to add that to the documentation so people know how to supply parameters. If i do it like i expected to do(as in the docs) the script would try to literally connect to "-BRHost localhost" image

So issue is therefore solved. Considering docs get updated.

One question though, how would i go with giving it the Debug switch as well?

eren-kemer commented 6 years ago

Correction: required syntax is as follows: -f="PRTG-VeeamBRStats2.ps1" -p="localhost" ""Monthly"" "5" "8" At least this works for me now.

eren-kemer commented 6 years ago

Please also add to the docs, as the syntax wasn't clear to me, looking at the screenshots on the blog.