-->

build-pysnmp-mib: convert cisco mib files to a pyt

2019-07-14 23:36发布

问题:

I'm trying to convert some .my files from the cisco site to .py files to use with pysnmp application but each one is failing.

ftp://ftp.cisco.com/pub/mibs/supportlists/wlc/wlc-supportlist.html

I have already set my SMIPATH to the current directory with all my mibs. But i'm receiving the same error on each of the cisco mibs.

root@testbox:/home/johnny# build-pysnmp-mib -o CISCO-CDP-MIB.py CISCO-CDP-MIB.my
Segmentation fault (core dumped)
Empty input
smidump -k -f python CISCO-CDP-MIB.my | /usr/bin/libsmi2pysnmp fails
make sure you are using libsmi version > 0.4.5 (or svn)

root@testbox:/home/johnny# build-pysnmp-mib -o CISCO-LWAPP-AAA-MIB.py CISCO-LWAPP-AAA-MIB.my
Segmentation fault (core dumped)
Empty input
smidump -k -f python CISCO-LWAPP-AAA-MIB.my | /usr/bin/libsmi2pysnmp fails
make sure you are using libsmi version > 0.4.5 (or svn)

回答1:

The build-pysnmp-mib script is obsolete since pysnmp 4.3. Please use mibdump.py tool (version 0.0.7 and up) from the pysmi package to produce pysnmp MIB modules. You could use produced modules with any pysnmp version.

The following fetched CISCO-LWAPP-MFP-MIB from http://mibs.snmplabs.com/asn1/ and compiled it into pysnmp form along with all other MIBs it depends on:

$ mibdump.py CISCO-LWAPP-MFP-MIB
Source MIB repositories: file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@mib@
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/notexts/@mib@
MIBs to compile: CISCO-LWAPP-MFP-MIB
Destination format: pysnmp
Also compile all relevant MIBs: yes

Created/updated MIBs: CISCO-LWAPP-AP-MIB, CISCO-LWAPP-DOT11-CLIENT-MIB, CISCO-LWAPP-DOT11-MIB, CISCO-LWAPP-MFP-MIB, CISCO-LWAPP-TC-MIB, CISCO-LWAPP-WLAN-MIB, CISCO-SMI, CISCO-TC, CISCO-VTP-MIB, ENTITY-MIB, RMON-MIB

You could pass mibdump.py URL(s) for authentic Cisco MIBs repository so it would fetch possibly more recent MIBs directly from there.

Alternatively, if you upgrade pysnmp to version 4.3, you would not need explicit MIB conversion -- it would be all done behind the scenes by pysnmp. Including ASN.1 MIB files search and download from the Internet.

Former (libsmi-based) conversion process is very fragile and buggy.