lordmilko / PrtgAPI

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

NotificationTrigger Deserialization issues w/SNMP Custom Sensors #146

Closed pyro3d closed 4 years ago

pyro3d commented 4 years ago

Describe the bug Clearly and concisely describe what you were trying to do, what happened and what you were expecting to happen Getting notification triggers on a SNMP Custom Sensor results in deserialization errors.

Steps to reproduce Put the relevant code from your application that caused the issue to happen in the code block below

PS /Users/%snip%> Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold
Get-Trigger : Could not deserialize channel 'RE Temperature' of threshold trigger '1' of object ID '47108'. Object may be in a corrupted state. Please check the notification triggers of object ID 47108 in the PRTG UI.
At line:1 char:54
+ ... "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold
+                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Get-NotificationTrigger], InvalidStateException
+ FullyQualifiedErrorId : PrtgAPI.InvalidStateException,PrtgAPI.PowerShell.Cmdlets.GetNotificationTrigger

What is the output of Get-PrtgClient -Diagnostic?

PS /Users/%snip%> Get-PrtgClient -Diagnostic

PSVersion      : 6.2.4
PSEdition      : Core
OS             : Darwin 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64
PrtgAPIVersion : 0.9.12
Culture        : en-US
CLRVersion     : .NETCoreApp,Version=v2.1
PrtgVersion    : 20.1.57.1745
PrtgLanguage   : english.lng

Additional context

Occurs on both 0.9.12-RELEASE and the 0.9.13-PRERELEASE

lordmilko commented 4 years ago

Hi @pyro3d,

Are you able to run the following commands and provide the output?

Set-PrtgClient -LogLevel All
Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Channel
Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold -Verbose

Please remove any sensitive information (e.g. server, username and passhash) from the response before posting it

pyro3d commented 4 years ago
PS /Users/%snip%> Set-PrtgClient -LogLevel All
PS /Users/%snip%> Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Channel

Name
SensorId     Id     LastValue LimitsEnabled UpperErrorLimit LowerErrorLimit ErrorLimitMessage
----
--------     --     --------- ------------- --------------- --------------- -----------------
RE Temperature            47108         2         48 °C         False
RE CPU Usage              47108         3          20 %         False
RE Memory Usage           47108         4          13 %         False
FPC Temperature           47108         5         48 °C         False
FPC CPU Usage             47108         6          20 %         False
FPC Memory Usage          47108         7          13 %         False
Yellow Alarms             47108         8           0 #          True
Red Alarms                47108         9           0 #          True               0
PS /Users/%snip%> Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold
Get-Trigger : Could not deserialize channel 'RE Temperature' of threshold trigger '1' of object ID '47108'. Object may be in a corrupted state. Please check the notification triggers of object ID 47108 in the PRTG UI.
At line:1 char:54
+ ... "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Get-NotificationTrigger], InvalidStateException
+ FullyQualifiedErrorId : PrtgAPI.InvalidStateException,PrtgAPI.PowerShell.Cmdlets.GetNotificationTrigger
lordmilko commented 4 years ago

I had forgotten to include the -Verbose parameter in my original reply. The last command should be

Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold -Verbose
pyro3d commented 4 years ago

Saw your update just after I replied. :)

PS /Users/%snip%> Get-Device "*EX2300-%snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold -Verbose
VERBOSE: Get-NotificationTrigger: Synchronously executing request https://%snip%/api/table.xml?id=47108&content=triggers&columns=content,objid&username=%snip%&passhash=%snip%
VERBOSE: Get-NotificationTrigger: <?xml version="1.0" encoding="UTF-8"?>
<triggers totalcount="1" listend="1">
<prtg-version>20.1.57.1745</prtg-version>
<item>
<content>{&quot;type&quot;:&quot;threshold&quot;,&quot;latency&quot;:&quot;60&quot;,&quot;offnotificationid&quot;:&quot;-1|None|&quot;,&quot;channel&quot;:&quot;RE Temperature&quot;, &quot;condition&quot;:&quot;Above&quot;,&quot;threshold&quot;:&quot;200&quot;,&quot;typename&quot;:&quot;Threshold Trigger&quot;,&quot;onnotificationid&quot;:&quot;35311|OpsGenie|http:HTTP&quot;,&quot;objectlink&quot;:&quot;&lt;a class=\&quot;sensorid47108 sensg sensormenu isnotpaused isnotfavorite\&quot; id=\&quot;47108\&quot; href=\&quot;sensor.htm?id=47108\&quot;&gt;Status&lt;/a&gt;&quot;}</content>
    <objid>1</objid>
   </item>
  </triggers>
VERBOSE: Get-NotificationTrigger: Synchronously executing request https://%snip%/api/table.xml?content=objects&columns=objid,name,parentid,tags,type,active,basetype&count=*&filter_objid=47108&username=%snip%&passhash=%snip%
VERBOSE: Get-NotificationTrigger: <?xml version="1.0" encoding="UTF-8"?>
<objects totalcount="0" listend="1">
<prtg-version>20.1.57.1745</prtg-version>
</objects>
Get-Trigger : Could not deserialize channel 'RE Temperature' of threshold trigger '1' of object ID '47108'. Object may be in a corrupted state. Please check the notification triggers of object ID 47108 in the PRTG UI.
At line:1 char:54
+ ... %snip%*" | Get-Sensor "Status" | Get-Trigger -Type Threshold -Verbose
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Get-NotificationTrigger], InvalidStateException
+ FullyQualifiedErrorId : PrtgAPI.InvalidStateException,PrtgAPI.PowerShell.Cmdlets.GetNotificationTrigger
lordmilko commented 4 years ago

I have a very strong suspicion the issue is that you're running PRTG 20.1.57.1745

This

https://%snip%/api/table.xml?content=objects&columns=objid,name,parentid,tags,type,active,basetype&count=*&filter_objid=47108&username=%snip%&passhash=%snip%

<?xml version="1.0" encoding="UTF-8"?>
<objects totalcount="0" listend="1">
<prtg-version>20.1.57.1745</prtg-version>
</objects>

Should return something. There was an issue (#143 ) detected with PRTG 20.1.57.1745 where filtering by ID does not work anymore. Can you please update to 20.1.57.1786 and advise how it goes?

pyro3d commented 4 years ago

I'll get a MW together and update. Hopefully should be this week. Thanks for the catch!

pyro3d commented 4 years ago

Updated PRTG and that was the issue! Thanks for the help @lordmilko!