VARIABLES(5)

๐Ÿ’– variables โ€” the manual, but make it cute ๐Ÿ’–

okay bestie, so this is the VARIABLES(5) page from Net-SNMP, and it's literally just about how you're supposed to write variable names when you talk to SNMP tools. no cap, that's the whole vibe. let's get into it ๐Ÿซถ


โœจ NAME โœจ

variables โ€” the format for specifying variable names to SNMP tools. that's it, that's the girl ๐Ÿ’…


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so. the syntax and semantics of management information in SNMP? that all comes from the definitions of MIB objects, which get loaded from one or more MIB files (or "MIB modules", same thing, different outfit).

here's the tea tho: those definitions are not strictly required for the SNMP protocol to operate correctly. like, the protocol will still do its thing. but SNMP client applications typically need them to display information in a way that actually means something to a human. it's giving "works fine but you can't read it" ๐Ÿ˜ญ

and the MIB file also serves as a design document when you're developing an SNMP agent (or sub-agent) that provides this information. it makes sure the client and the server share a common understanding about what the management information actually represents. communication, queen ๐ŸŽ€


๐Ÿ‘‘ OIDs ๐Ÿ‘‘

MIB objects are specified using Object Identifiers (OIDs), and they can take a number of forms. important note before we go any further: all of the examples in this section refer to the same MIB object. same girl, different outfits. periodt.

๐Ÿ”ข Numeric OIDs

the fundamental format of an OID is a sequence of integer values (or "subidentifiers"), typically written using dots to separate the individual subidentifiers:

.1.3.6.1.2.1.1.1

this is the format that's used within the SNMP protocol itself, in the packets that get sent over the network. this is the raw one, the no-makeup one ๐Ÿง–

this form of representing an OID does not require MIB files or MIB object definitions to be available. but โ€” and this is the catch โ€” it does rely on the client application and/or network administrator knowing what a given numeric OID actually refers to. so for anyone just starting out with SNMP, it's not a particularly helpful representation. it's giving "here's a number, good luck bestie" ๐Ÿ’€

you can get this format by giving the command-line option -On to most Net-SNMP commands.

๐ŸŒˆ Full OID path

a similar (but somewhat more informative) format uses the same dotted list representation, except the numeric subidentifiers get replaced by names taken from the relevant MIB file(s):

.iso.org.dod.internet.mgmt.mib-2.system.sysDescr

this uniquely identifies a particular MIB object (just like the numeric OID does), but the list of names should hopefully give you some indication as to what information this object represents. so much more readable ๐Ÿ’–

but it does rely on the relevant MIB files being available (which, lowkey, is true of all formats other than the purely numeric OID). also โ€” and this is so real โ€” such OIDs tend to be fairly long! ๐Ÿ˜ญ

you can get this format by giving the command-line option -Of to most Net-SNMP commands.

there's also a variant of this, typically used when writing OIDs in descriptive text rather than when running programs. you combine the name and the numeric subidentifier:

.iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1)
.sysDescr(1)

iconic, honestly. both worlds, one OID โœจ

๐Ÿฆ‹ Module-qualified OIDs

an alternative way to (more-or-less) uniquely specify an OID is to give the name of the MIB object, together with the MIB module where it's defined:

SNMPv2-MIB::sysDescr

MIB object names are unique within a given module, so as long as there aren't two MIB modules with the same name (which is unusual, though not unheard of), this format specifies the desired object in a reasonably compact form. it also makes it relatively easy to find the definition of the MIB object. chef's kiss ๐Ÿ‘‘

this is the default format for displaying OIDs in Net-SNMP applications. you can also specify it explicitly by giving the command-line option -OS to most Net-SNMP commands.

๐ŸŒŸ Object name

possibly the most common form for specifying MIB objects is using the name of the object alone โ€” without the full path or the name of the module that defines it:

sysDescr

this is by far the shortest and most convenient way to refer to a MIB object. main character energy, truly โœจ

but here's the warning bestie: the danger is that if two MIB modules each define a MIB object with the same name (which is perfectly legal in some circumstances), then it's not necessarily clear which MIB object is actually meant. for day-to-day use โ€” particularly when you're using standard MIB objects โ€” this is probaby safe. but it's important to be aware of the potential ambiguities. ๐Ÿ‘€

you can get this format by giving the command-line option -Os to most Net-SNMP commands.

๐Ÿ’œ UCD-format

previous versions of the code (UCD v4.x and earlier) used a simple approach to shortening the way OIDs were specified. if the full path of the OID began with .iso.org.dod.internet.mgmt.mib-2, then this prefix was removed from the OID before displaying it. all other OIDs were displayed in full.

similarly, if an OID was passed to the UCD library that did not begin with a dot (and wasn't in the module::name format), then that same prefix was prepended. so the example OID from the formats listed above would be given or displayed as:

system.sysDescr

ngl the inconsistent handling of OIDs โ€” depending on where they sat in the OID tree โ€” proved to be more trouble than it was worth, and this format is no longer recommended. it's giving deprecated, we don't do that anymore ๐Ÿ™ˆ

the previous behaviour can still be obtained by giving the command-line option -Ou (for displaying output), or -Iu (for interpreting input OIDs without a leading dot) to most Net-SNMP commands.


๐Ÿ” SEE ALSO ๐Ÿ”


๐Ÿ’€ BUGS ๐Ÿ’€

the parser of the MIB files file is not expected to handle bizarre (although correct) interpretations of the ASN.1 notation. so like, don't come for her with the weird stuff, she's not built for that fr fr ๐Ÿ˜ญ


and that's the whole page bestie!! this was Net-SNMP version V5.9.5.2, dated 01 Oct 2010. slay, go forth and name your variables correctly ๐Ÿ’…โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from