Skip to content

Importing a MIB ​

A MIB file describes the objects a device offers over SNMP: their names, numbers, types, units and the names of their values. Importing one lets you pick objects from a list instead of typing object identifiers, and gives the sensors it makes their names, units and state names. A scalar becomes an snmp_custom_oid sensor. One row of a table becomes an snmp_custom_table sensor with the columns you pick. Nothing new runs on the probe: the sensors are the two that already exist, with their parameters filled in.

This is not the LibreNMS import. That one turns the device definitions of a LibreNMS checkout into device templates, and reads the checkout's MIB files only to turn object names into numbers. This one reads a MIB file you give it and makes sensors for the objects you choose.

Using it ​

Open a device and choose Import from MIB.

  1. Choose the files. Pick one or more MIB files, or paste the text. A file may hold several modules. If the MIB imports a module that is not built in (a vendor's own ...-SMI module, for example), add that file too: the reader tells you which module is missing, and leaves out only the objects that depend on it. To pick from a standard module without a file, tick it in the list of built-in modules.
  2. Pick objects. The scalars and the tables are listed with their unit, their type and the MIB's own description, and a search box narrows them. For a table, tick the columns, then say which row: by its index (3, 1.4) or by its name, with the column that holds the names (the interface description, say). A row chosen by name is found again on every poll, so the sensor follows a row the device renumbers.
  3. Review and add. The sensors that will be made are shown with their names, which you can change, and with notes where something deserves a word (a counter is read as the raw number that only grows, not as a rate; a text object has no number to graph). Add creates them through the same route as the Add sensor form, so access rules, audit and limits are the same.

The Import from MIB dialog with a table open

The pick step, with a MIB written for the tests: two scalars and a counter ticked, and two columns of a table ticked, the row chosen by name. In the dark theme: pick. The review step, where the sensors can be renamed and the notes read: light, dark. And the device with the sensors that were made: light, dark.

What is filled in ​

Sensor settingComes from
NameThe object's name, split into words (ifInOctets becomes If in octets). A table row is named <table>: <row>.
UnitThe UNITS clause: percent becomes %, milliseconds becomes ms, degrees Celsius becomes °C, bytes becomes B. A unit that is not recognised is kept as the MIB wrote it, if it is short. A TimeTicks object is in seconds.
ScaleA DISPLAY-HINT such as d-1 (tenths) or a fraction in the units (tenths of a degree, centi-degrees, 1/100 volts). The raw value is multiplied by the scale, so a temperature of 235 tenths is 23.5.
Value namesThe named values of an integer: up(1), down(2). Names that say something about health get a health (ok, normal, online up; degraded, warning, nonCritical warning; failed, critical, down down); names that say nothing, such as other or notPresent, get none, so that no guess turns a sensor red.

Objects with no read access (not-accessible, accessible-for-notify, write-only) are not listed, and neither are the index columns of a table that cannot be read: the table's index is shown so you know what a row is.

Which MIBs are read ​

SMIv2 (RFC 2578) and the SMIv1 constructs still in use: OBJECT-TYPE with ACCESS and STATUS mandatory, TRAP-TYPE (skipped), Counter, Gauge and NetworkAddress, and tables with INDEX or AUGMENTS. Textual conventions, enumerations, ranges and display hints are followed through the modules. Notifications, compliance statements, object groups and macro definitions are skipped.

A definition the reader cannot parse is reported with its line number and skipped; the rest of the module is still read. A definition whose place in the tree cannot be worked out (a name that is not defined, an import from a module that is missing, a circle of names) is listed as unresolved with the reason, and is never guessed.

Built-in modules ​

A small set of standard modules ships with Probeward, so that a vendor MIB can import from it and so that the common objects can be picked without a file: SNMPv2-SMI, SNMPv2-TC, SNMPv2-CONF, RFC1155-SMI, RFC-1212, RFC-1215, RFC1213-MIB, SNMPv2-MIB, IF-MIB, ENTITY-MIB, ENTITY-SENSOR-MIB, HOST-RESOURCES-MIB, SNMP-FRAMEWORK-MIB and INET-ADDRESS-MIB. They are condensed rewrites of the object definitions of IETF standards (the names, numbers, types, units and named values; the descriptions are left out), which the IETF allows to be redistributed.

No vendor MIB is bundled. Many vendor MIBs forbid redistribution, so you bring the files of the devices you monitor. Probeward does not keep them: the files are read when you ask, and nothing is stored.

Limits and what is refused ​

The text of a MIB file is untrusted input. The reader bounds everything it does:

LimitValue
Size of one file4 MiB
All files of one request12 MiB (the request body is cut at 16 MiB)
Tokens in a file800,000
Modules in one request40, and 16 in one file
Definitions in a module40,000
Nesting of brackets32
Names followed to place one object200
Entries kept of one enumeration512
Scalars, tables and columns listed5,000 scalars, 2,000 tables, 100 columns a table (the answer says when it was cut)

A file that is too big, has too many tokens, has a string that is not closed, or is not a MIB at all is refused with the file name and the line. Garbage never crashes the server or stalls it; the tests feed it damaged and random input to check that.

The API ​

Both routes belong to a device and need the right to configure it. They compute from the text sent and store nothing, so they are not audited; creating the sensors is, as usual.

POST /api/v1/devices/{id}/mib/inspect
{"files": [{"name": "EXAMPLE-MIB.mib", "text": "..."}], "builtin": ["IF-MIB"]}

answers the catalogue: the modules (with their missing imports, unresolved definitions and read faults), the scalars (oid is the instance to read, ending in .0) and the tables, each with its columns, index and a suggested name column.

POST /api/v1/devices/{id}/mib/drafts
{"files": [...], "builtin": [], "selections": [
  {"type": "scalar", "name": "exTemperature"},
  {"type": "table", "table": "exProbeTable", "columns": ["exProbeValue"],
   "row": {"by": "name", "name": "intake"}}
]}

answers drafts (each with kind, name, params and notes) and errors (the position of a selection that gave no sensor, and why). Send each draft to POST /api/v1/sensors as it is. The parameters have already been checked the way that route checks them. See the API reference.

Verification ​

The reader was checked against:

  • Modules written for the tests in SMIv2 and in SMIv1, with the standard modules they import, covering scalars, tables, AUGMENTS, enumerations, display hints, units, counters, text, read-write and not-accessible objects, a module in two files and two modules in one, a name defined in two modules, and an import that is missing.
  • Hostile and damaged input: files over the limits, brackets 100,000 deep, names of 10,000 characters, circular and 5,000-step chains of names, an enumeration of 100,000 entries, arcs that do not fit, and 1,500 mutations each of two modules, 1,500 random token sequences and 500 random byte strings, none of which may panic or stall.
  • A large real corpus: the MIB folder of a LibreNMS checkout, 4,863 files of every vendor. 4,839 are read (99.5 %), with 85,836 scalars and 21,936 tables listed in about 40 seconds on a loaded machine. The 24 refused files are over the size limit or hold text that is not a MIB. The corpus is not in this repository; the test runs when PROBEWARD_TEST_MIB_CORPUS names a folder. The object identifiers the vendor sensors read were checked against the vendors' MIBs with this reader.

Not covered: MIBs that use ASN.1 features no SNMP MIB uses; the SIZE and range constraints are skipped, not checked; and the built-in modules hold only the parts named above, so a vendor MIB that imports an object from another standard module (Printer-MIB, say) needs that module added as a file.

AGPL-3.0-only