Announcement

Collapse
No announcement yet.

Trouble with UInt64 values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trouble with UInt64 values

    I'm writing a script for SNMP get's and all is working well until I have to get a UInt64 value.

    Code:
    Imports System.Collections.Generic
    Imports SnmpSharpNet
    
    Sub Main(parm as object)
    Try
    Dim host As String = "192.168.148.101"
    Dim community As String = "public"
    Dim requestOid As String
    Dim result As Dictionary(Of Oid, AsnType)
    requestOid = "1.3.6.1.2.1.31.1.1.1.6"
    Dim snmp As SimpleSnmp = New SimpleSnmp(host, community)
    result = snmp.Walk(SnmpVersion.Ver1, requestOid)
    
    If result IsNot Nothing Then
    
    Dim kvp As KeyValuePair(Of Oid, AsnType)
    hs.WriteLog("Script", "Test1")
    
    For Each kvp In result
    
    hs.WriteLog("Script", "Test2")
    
    hs.WriteLog("Script", kvp.Key.ToString())
    hs.WriteLog("Script", SnmpConstants.GetTypeName(kvp.Value.Type))
    hs.WriteLog("Script", kvp.Value.ToString())
    
    Next
    
    End If
    
    
    Catch ex As Exception
    hs.WriteLog("Warning", ex.Message)
    End Try
    
    End Sub
    According to de SNMP Sharp documentation
    C# TYPE SNMP#NET CLASS
    Int32. Counter32, Integer32
    UInt32 Gauge32, UInteger32
    UInt64 Counter64
    If I run the script on a OID with a Counter64 property the script only prints Test1.

    I've been searching for quite a while but I don't understand what I need to adjust.

    #2
    Never mind, I found the issue.
    It wasn't the script. It was the SNMP version. Only SNMPv2 supports Counter64.

    I though I was running snmp 2 but the documentation has an error in it
    Members
    Ver1 0 SNMP version 1
    Ver2 1 SNMP version 2c
    Ver3 3 SNMP version 3
    This is incorrect since the script does work with
    Code:
     result = snmp.Walk(SnmpVersion.Ver2, requestOid)

    Comment

    Working...
    X