SNMP tool and API interfaces to MPOD

SNMP protocol

Monitoring and control of the properties of a MPOD crate system is provided via crate controller Ethernet connection via Simple Network Management Protocol.

SNMP is used extensively with IT Ethernet attached equipment, e.g. servers in computer centers, and a rich set of tools and APIs are available. The relative complexity of the object hierarchy which needs to be defined, see MIB below, for a system to be integrated is significant but attractive.

MIB object definition

The Management Information Base (MIB) is a formal description of a set of network objects that can be managed using SNMP. The format of the MIB is defined as part of the SNMP standard, where derived MIBs extend the management information base. A MIB overview including RFC, etc. and standards organization can be found elsewhere, e.g. https://en.wikipedia.org/wiki/Management_information_base

The WIENER MPOD MIB (WIENER-CRATE-MIB.txt) can be downloaded from http://file.wiener-d.com/software/net-snmp/

Objects defined in the MIB are hierarchical addressed using an OID (Object ID) have attributes like type, etc. The OID of a MPOD crate’s main switch is .1.3.6.1.4.1.19947.1.1.1.0, which clearly shows the dotted object hierarchy.

SNMP API

The pysnmp (etingof@gmail.com) python API is used to interface mpod.py to the crate controller.

To give pysnmp access to text information, e.g. symbolic rather than raw oid object identifiers, use pydump.py to translate WIENER-CRATE-MIB.txt into WIENER-CRATE-MIB.py as shown below.

$ cd $KARABO/devices/pysnmp/pysmi-0.1.0/scripts
ensure that SNMPv2-CONF.txt , SNMPv2-SMI.txt, SNMPv2-TC.txt are in ~/.snmp/mibs
$ python mibdump.py --ignore-errors ~/.snmp/mibs/WIENER-CRATE-MIB.txt
Source MIB repositories: file:///home/xbeam/.snmp/mibs
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/notexts/@mib@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: /home/xbeam/.pysnmp/mibs
MIBs excluded from code generation: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMP-FRAMEWORK-MIB, SNMP-TARGET-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM, TRANSPORT-ADDRESS-MIB
MIBs to compile: WIENER-CRATE-MIB
Destination format: pysnmp
Parser grammar cache directory: not used
Also compile all relevant MIBs: yes
Rebuild MIBs regardless of age: no
Dry run mode: no
Create/update MIBs: yes
Byte-compile Python modules: yes (optimization level no)
Ignore compilation errors: yes
Generate OID->MIB index: no
Generate texts in MIBs: no
Try various filenames while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, WIENER-CRATE-MIB
Missing source MIBs:
Ignored MIBs:
Failed MIBs:
$ find ~/ -name "WIENER-CRATE-MIB*" -print
/home/xbeam/.pysnmp/mibs/WIENER-CRATE-MIB.py
/home/xbeam/.pysnmp/mibs/__pycache__/WIENER-CRATE-MIB.cpython-34.pyc
/home/xbeam/.snmp/mibs/WIENER-CRATE-MIB.txt

SNMP tools

NetSNMP (www.net-snmp.org) provides a set of command line tools useful for diagnostics. MPOD usage example are shown below - NetSNMP and the MIBbrowser of Ireasoning are installed, the current directory is ireasoning/mibbrowser, and WIENER-CRATE-MIB.txt is in ireasoning/mibbrowser/. Ireasoning’s freeware installation defines all MIBs, like SNMPv2-SMI in the examples below, which would otherwise be missing, and gives access to their MIB browser (not used but probably useful).

Many NetSNMP command line tools exist (snmp-bridge-mib, snmpcheck, snmpdf, snmpinform, snmpstatus, snmptranslate, snmpvacm, snmpbulkget, snmpconf, snmpget, snmpnetstat, snmptable, snmptrap, snmpwalk, snmpbulkwalk, snmpdelta, snmpgetnext, snmpset, snmptest, snmpusm) examples of the most frequently used whilst developing mpod.py are given below - there may be some jewels in there that have not been used!

Example NetSMNP snmpwalk

Targeting snmpwalk directly at the MPOD hostname returns details of the controller firmware

$ which snmpwalk
/usr/bin/snmpwalk
$ snmpwalk --version
NET-SNMP version: 5.7.2
$ pwd
/home/xbeam/cy_caslab_work/snmp/ireasoning/mibbrowser

$ snmpwalk -v 2c -M mibs -m WIENER-CRATE-MIB -c public exflqr18575
SNMPv2-SMI::mib-2.1.1.0 = STRING: "WIENER MPOD (3783004, MPOD 2.1.4152.0,
 MPODslave 1.10, MPOD-BL 2.2439.0)"
SNMPv2-SMI::mib-2.1.2.0 = OID: WIENER-CRATE-MIB::sysMainSwitch.0
SNMPv2-SMI::mib-2.1.3.0 = Timeticks: (9536416) 1 day, 2:29:24.16
SNMPv2-SMI::mib-2.1.4.0 = ""
SNMPv2-SMI::mib-2.1.5.0 = ""
SNMPv2-SMI::mib-2.1.6.0 = ""
SNMPv2-SMI::mib-2.1.7.0 = INTEGER: 79

$ snmpwalk -v 2c -O n -M mibs -m WIENER-CRATE-MIB -c public exflqr18575
.1.3.6.1.2.1.1.1.0 = STRING: "WIENER MPOD (3783004, MPOD 2.1.4152.0,
 MPODslave 1.10, MPOD-BL 2.2439.0)"
.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.19947.1.1.1.0
.1.3.6.1.2.1.1.3.0 = Timeticks: (9569167) 1 day, 2:34:51.67
.1.3.6.1.2.1.1.4.0 = ""
.1.3.6.1.2.1.1.5.0 = ""
.1.3.6.1.2.1.1.6.0 = ""
.1.3.6.1.2.1.1.7.0 = INTEGER: 79

There are a number of sub-levels hierachies which can be targeted, the most comprehensive is ‘crate’ which returns all objects

$ snmpwalk -v 2c  -M mibs -m WIENER-CRATE-MIB -c guru exflqr18575 crate
WIENER-CRATE-MIB::sysMainSwitch.0 = INTEGER: on(1)
WIENER-CRATE-MIB::sysStatus.0 = BITS: 80 mainOn(0)
WIENER-CRATE-MIB::sysHardwareReset.0 = INTEGER: 0
WIENER-CRATE-MIB::sysFactoryDefaults.0 = INTEGER: off(0)
WIENER-CRATE-MIB::system.12.0 = Hex-STRING: 01 08 00 00 00 00 00 00 00 00
 00 00 00 00 00 00
WIENER-CRATE-MIB::outputNumber.0 = INTEGER: 32
WIENER-CRATE-MIB::outputIndex.u100 = INTEGER: u100(101)
WIENER-CRATE-MIB::outputIndex.u101 = INTEGER: u101(102)
... far too long to display

snmpwalk -v 2c -O n -M mibs -m WIENER-CRATE-MIB -c guru exflqr18575 crate
.1.3.6.1.4.1.19947.1.1.1.0 = INTEGER: on(1)
.1.3.6.1.4.1.19947.1.1.2.0 = BITS: 80 mainOn(0)
.1.3.6.1.4.1.19947.1.1.4.0 = INTEGER: 0
.1.3.6.1.4.1.19947.1.1.5.0 = INTEGER: off(0)
.1.3.6.1.4.1.19947.1.1.12.0 = Hex-STRING: 01 08 00 00 00 00 00 00 00 00 00
 00 00 00 00 00
.1.3.6.1.4.1.19947.1.3.1.0 = INTEGER: 32
.1.3.6.1.4.1.19947.1.3.2.1.1.101 = INTEGER: u100(101)
.1.3.6.1.4.1.19947.1.3.2.1.1.102 = INTEGER: u101(102)
... far too long to display

The target regions of interest is viewed by selecting the corresponding OID level. Below the outputIndex of all channels is viewed

$ snmpwalk -v 2c -M mibs -m WIENER-CRATE-MIB -c guru exflqr18575
 .1.3.6.1.4.1.19947.1.3.2.1.1
WIENER-CRATE-MIB::outputIndex.u100 = INTEGER: u100(101)
WIENER-CRATE-MIB::outputIndex.u101 = INTEGER: u101(102)
WIENER-CRATE-MIB::outputIndex.u102 = INTEGER: u102(103)
WIENER-CRATE-MIB::outputIndex.u103 = INTEGER: u103(104)
WIENER-CRATE-MIB::outputIndex.u104 = INTEGER: u104(105)
WIENER-CRATE-MIB::outputIndex.u105 = INTEGER: u105(106)
WIENER-CRATE-MIB::outputIndex.u106 = INTEGER: u106(107)
WIENER-CRATE-MIB::outputIndex.u107 = INTEGER: u107(108)
WIENER-CRATE-MIB::outputIndex.u200 = INTEGER: u200(201)
WIENER-CRATE-MIB::outputIndex.u201 = INTEGER: u201(202)
....

Example NetSMNP snmptranslate

OIDs are converted to their names by

$ snmptranslate -M mibs -m WIENER-CRATE-MIB .1.3.6.1.4.1.19947.1.3.2.1.1.101
WIENER-CRATE-MIB::outputIndex.u100

Example NetSMNP snmpget

Target name, or OIDs, leaf values can be read with snmpget

$ snmpget -v 2c -M mibs -m WIENER-CRATE-MIB -c guru exflqr18575 outputVoltage.u100
WIENER-CRATE-MIB::outputVoltage.u100 = Opaque: Float: 13.000000 V

Example NetSMNP snmpset

Target names, or OIDs, leaf can be set with snmpset

$ snmpset -v 2c -M mibs -m WIENER-CRATE-MIB -c guru exflqr18575 outputVoltage.u100 F 4.0
WIENER-CRATE-MIB::outputVoltage.u100 = Opaque: Float: 4.000000 V
$ snmpget -v 2c -M mibs -m WIENER-CRATE-MIB -c guru exflqr18575 outputVoltage.u100
WIENER-CRATE-MIB::outputVoltage.u100 = Opaque: Float: 4.000000 V