Snmp pulling and OID types

I am pulling a fair number of oid’s on a plugin and trying to see if there is a way to specify the type() when it pulls particular OIDs. something like this below because they all just come across as strings even though they don’t originate as strings in the devices. usually this isn’t a problem but one OID in particular is hex and just is getting an unusable value. Partial snippet below.

   SNMPTree(
        base = ".1.3.6.1.4.1.2636.3.60.1.1.1.1",
            oids = [
                OIDEnd(),
                '1', # jnxDomCurrentAlarms
                HEX('4'), # jnxDomCurrentWarnings
                INT('5'), # jnxDomCurrentRxLaserPower
                '6', # jnxDomCurrentTxLaserBiasCurrent
                '7', # jnxDomCurrentTxLaserOutputPower
       ],

)

Hi.

This will not work with HEX and INT. You need to convert the values in a parse function.

Rg, Christian

you might use OIDBytes(), this gives you a list of int, for the OID in question

SNMPTree(
            base='.1.0.8802.1.1.2.1.4.1.1',  # LLDP-MIB::lldpRemEntry
            oids=[
                OIDEnd(),  #
                '4',  # lldpRemChassisIdSubtype
                OIDBytes('5'),  # lldpRemChassisId
                '6',  # lldpRemPortIdSubtype
                OIDBytes('7'),  # lldpRemPortId
                '8',  # lldpRemSysName
                '9',  # lldpRemSysName
                '10',  # lldpRemSysDesc
                '11',  # lldpRemSysCapSupported
                '12',  # lldpRemSysCapEnabled
            ]
        ),

2 Likes

@thl-cmk once again you have saved me. that got it in a format i was able to work with :slight_smile: