MIB retrievers

APIs to create MIB-aware retriever classes for asynchronous SNMP polling.

libsmi provides a command line tool (smidump) which can parse MIB definitions and dump them as Python data structures.

To create a new MIB-aware retriever class, inherit from the MibRetriever class and set the class-variable “mib” to point to a MIB data structure as dumped by libsmi’s smidump command.

The class will be imbued with knowledge of the MIB in question, and several convenience methods to work with data retrieval. An instance of a MibRetriever class is tied to a TwistedSNMP AgentProxy and uses this to allow asynchronous data retrieval.

Bases: object

Representation of a MIB object.

Member attributes:


The name of the MIB module where the object originated.


The object’s textual name.


The full object identifier


If the object’s syntax indicates it is an enumerated value, this dictionary will hold mappings between the enumerations textual names and integer values. As a simplifying case, SNMPv2-TC::TruthValues will be deciphered as enums of boolean values.

Translate an SNMP value into something python-like.

If the syntax of this object is an Enumeration, value will be translated from and int to a str object. If it is an SNMPv2-TC::TruthValue, it will be translated from int to bool.

Bases: object

Base class for functioning MIB retriever classes.

Returns the MIB module

Gets next sub-object of the named object

Retrieve the contents of a single MIB table column.

Returns a deferred whose result is a dictionary:

{ row_index: column_value }

Retrieves the value of a specific column for a given row index

Retrieve a set of table columns.

The table columns may come from different tables, as long as the table rows are indexed the same way.

Returns a deferred whose result is a dictionary:

{ row_index: MibTableResultRow instance }

Table retriever and formatter.

Retrieves an entire MIB table. Returns a deferred whose result is a dictionary:

{ row_index: MibTableResultRow instance }

Each dictionary key is a row index (an oid suffix tuple). Each dictionary value is a MibTableResultRow instance, which can be accessed as both a dictionary and a list.

Translate result values to pythonic values according to object syntax.

Given a table result from one of this object’s retrievers, every column object will have it’s to_python translation rules applied. This is useful to insert into a callback chain for result formatting.

Bases: nav.errors.GeneralException

MIB retriever error

Bases: type

Metaclass to create new functional MIB retriever classes.

The MibRetriever base class uses this as its metaclass. All new MIB retrievers should inherit inherit directly from the MibRetriever class.

Bases: object

Description of a MIB table structure.

Build and return a MibTableDescriptor for a MIB table.

mib – a MibRetriever instance. table_name – the name of the table from the mib.

Build table descriptors for all tables in a mib.

mib – MibRetriever instance

Bases: dict

A result row from a MIB table.

Acts as a dictionary. The row index is available through the integer key 0, or as the member attribute ‘index’.

Bases: nav.mibs.mibretriever.MibRetriever

Queries and chains the results of multiple MIB instances using community indexing.

Useful for Cisco devices, whose SNMP agents employ multiple BRIDGE-MIB instances, one for each active VLAN, each indexable via a modified SNMP community.

Add the mixin to the list of base classes of a MibRetriever descendant class, and override any querying method that should work across multiple instances. The overriden method should use a call to self._multiquery().

Verifies whether a given MIB object has a syntax that can be considered a text type.