Score:0

Why snmpget output is different when MIBS environment variable is defined?

us flag
$ export MIBS=
$ snmpget -Oqv -v 2c -c public 10.xxx.yyy.zzz .1.3.6.1.4.1.3375.2.1.14.3.2.0
"ACTIVE"

but

$ export MIBS=F5-BIGIP-SYSTEM-MIB
$ snmpget -Oqv -v 2c -c public 10.xxx.yyy.zzz .1.3.6.1.4.1.3375.2.1.14.3.2.0
ACTIVE

Why that difference in output when MIBS environment variables has a value?

Score:1
pt flag

The SNMP mib defines the data types for your SNMP OIDs, so with the MIB loaded it can display a "formatted" version of the value rather than displaying the raw value.

For example, compare:

MIBS= snmpget -v2c -c public 192.168.1.1 1.3.6.1.2.1.2.2.1.3.1
iso.3.6.1.2.1.2.2.1.3.1 = INTEGER: 24

With:

$ snmpget -v2c -c public 192.168.1.1 1.3.6.1.2.1.2.2.1.3.1
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)

When mibs are loaded, snmpget knows how to interpret the value.


In the particular case in your question, the mibs says, "display that value as a string".

Score:1
vn flag

To be more specific.

Without MIB documents, an SNMP tool can only tell the very basic data types defined by the protocol itself,

  • INTEGER
  • OCTET STRING
  • NULL
  • OBJECT IDENTIFIER
  • IpAddress
  • Counter32
  • Gauge32
  • TimeTicks
  • Opaque
  • NetAddress
  • Counter64

Since data are encoded in ASN.1 BER, the decoding algorithm can extract such data types from raw bytes over the wire.

Thus, when you run NET-SNMP's snmpget command without MIB documents, it merely decodes the data as OCTET STRING and prints as "ACTIVE".

However, MIB documents in SMI v1 or v2 allow customized data types to be defined upon such basic types via the so-called "Textual Conventions". And in your case, MIB document F5-BIGIP-SYSTEM-MIB defines the object .1.3.6.1.4.1.3375.2.1.14.3.2 as below,

sysCmFailoverStatusStatus OBJECT-TYPE 
    SYNTAX LongDisplayString
    MAX-ACCESS read-only
    STATUS current
    DESCRIPTION
        "The failover status on the system."
    ::= { sysCmFailoverStatus 2 }

The actual data type is LongDisplayString defined in F5-BIGIP-COMMON-MIB,

LongDisplayString ::= TEXTUAL-CONVENTION
    DISPLAY-HINT "1024a"
    STATUS       current
    DESCRIPTION  "A longer version of SNMPv2-TC::DisplayString."
    SYNTAX       OCTET STRING (SIZE (0..1024))

Thus, when you ask NET-SNMP snmpget command to load MIB documents, it is fully aware of the data type of LongDisplayString and prints ACTIVE.

So, you see even the only observable change is just the quotes, a lot happens behind the scenes.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.