lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
305 stars 38 forks source link

Get-ObjectLog - Could not deserialize value #214

Closed mup07 closed 3 years ago

mup07 commented 3 years ago

Bug description We have problem while running the command "Get-ObjectLog". We get the error:

Get-ObjectLog : Could not deserialize value '406' as it is not a valid member of type 'PrtgAPI.LogStatus'. Could not process XML '<status>FTP Connection Mode</status><status_raw>406</status_raw><message><div 
class="logmessage">Connection established using implicit mode.<div class="moreicon"></div></div></message>'.
At line:1 char:1
+ Get-ObjectLog -StartDate $(get-date("13.04.2021 01:42:00")) -EndDate  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ObjectLog], XmlDeserializationException
    + FullyQualifiedErrorId : PrtgAPI.XmlDeserializationException,PrtgAPI.PowerShell.Cmdlets.GetObjectLog

Steps to reproduce While the analysis, we could reproduce the error by filter the Logs to the specific sensor and datetime:

Get-ObjectLog -StartDate $(get-date("13.04.2021 01:42:00")) -EndDate $(get-date("11.04.2021 01:00:00")) -Object (Get-Sensor -Id 3561)

The sensor is a default type of FTP Sensor on PRTG:

DisplayLastValue   : 125 msec
LastValue          : 125
BaseType           : Sensor
Url                : /sensor.htm?id=3561
Interval           : 00:15:00
InheritInterval    : False
Access             : Inherited
Position           : 7
Status             : Up
Message            : OK (221 - Session Ended. Downloaded 0KB, Uploaded 0KB. Goodbye abc from x.x.x.x.)
Id                 : 3561
ParentId           : 3530
Tags               : {ftpsensor}
DisplayType        : FTP
Type               : Sensor (ftp)
Active             : True

We were able to limit this period to a single log entry. It is an entry with the status "FTP Connection Mode". No such status name or status ID 406 (from the error message) is listed in the PRTG manuals. (Source: PRTG Manual: Single Object Status)

What is the output of Get-PrtgClient -Diagnostic?

PSVersion      : 5.1.19041.906
PSEdition      : Desktop
OS             : Microsoft Windows 10 Pro
PrtgAPIVersion : 0.9.14
Culture        : de-CH
CLRVersion     : 528372
PrtgVersion    : 21.1.65.1767
PrtgLanguage   : Unknown

Can you reproduce this situation? Or exists already a solution for this?

lordmilko commented 3 years ago

Hi @mup07,

In LogStatus.cs we have the following:

https://github.com/lordmilko/PrtgAPI/blob/37041f9baedb44bbca809dacccab6bed0120ead3/src/PrtgAPI/Enums/Deserialization/LogStatus.cs#L145-L154

Evidently, at some point I became aware of the fact there was a 406 FTP Mode, but I had no idea what it was, how to generate it, or how it differed from the other 407 FTP Mode! Several years later, we finally have the answer!

I have pushed a commit for a pre-release version of the next version of PrtgAPI; if it successfully builds in the next 30 minutes, you'll be able to manually download the PrtgAPI.zip artifact that is created as per the manual installation instructions

Regards, lordmilko

mup07 commented 3 years ago

Hi @lordmilko

It worked very good. Thanks for the fast reply.

Regards, mup07

lordmilko commented 3 years ago

Hi @mup07,

Please be advised PrtgAPI 0.9.15 has now been released which includes a fix for this issue

To update PrtgAPI, please run Update-Module PrtgAPI and reopen PowerShell

Regards, lordmilko