Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork58
etingof/pysmi
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
PySMI is a pure-Python implementation ofSNMP SMI MIB parser.This tool is designed to turn ASN.1 MIBs into various formats. As of this moment,JSON andpysnmp modules can be generatedfrom ASN.1 MIBs.
- Understands SMIv1, SMIv2 and de-facto SMI dialects
- Turns MIBs into pysnmp classes and JSON documents
- Maintains an index of MIB objects over many MIB modules
- Automatically pulls ASN.1 MIBs from local directories, ZIP archives,HTTP and FTP servers
- 100% Python, works with Python 2.4 up to Python 3.7
Rendered PySMI documentation can be found atpysmi site.
If you are using pysnmp, you might never notice pysmi presence - pysnmpcalls pysmi for MIB download and compilation behind the scenes (you canstill can do that manually by invokingmibdump.py tool).
To turn ASN.1 MIB into a JSON document, callmibdump.py tool like this:
$ mibdump.py --generate-mib-texts --destination-format json IF-MIBSource MIB repositories: file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@mib@Borrow missing/failed MIBs from: http://mibs.snmplabs.com/json/fulltexts/@mib@Existing/compiled MIB locations: Compiled MIBs destination directory: .MIBs excluded from code generation: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI,RFC1158-MIB, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TMMIBs to compile: IF-MIBDestination format: jsonParser grammar cache directory: not usedAlso compile all relevant MIBs: yesRebuild MIBs regardless of age: yesDo not create/update MIBs: noByte-compile Python modules: no (optimization level no)Ignore compilation errors: noGenerate OID->MIB index: noGenerate texts in MIBs: yesKeep original texts layout: noTry various filenames while searching for MIB module: yesCreated/updated MIBs: IANAifType-MIB, IF-MIB, SNMPv2-MIBPre-compiled MIBs borrowed: Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TCMissing source MIBs: Ignored MIBs: Failed MIBs:JSON document build fromIF-MIB modulewould hold information such as:
{ "ifMIB": { "name": "ifMIB", "oid": "1.3.6.1.2.1.31", "class": "moduleidentity", "revisions": [ "2007-02-15 00:00", "1996-02-28 21:55", "1993-11-08 21:55" ] }, ... "ifTestTable": { "name": "ifTestTable", "oid": "1.3.6.1.2.1.31.1.3", "nodetype": "table", "class": "objecttype", "maxaccess": "not-accessible" }, "ifTestEntry": { "name": "ifTestEntry", "oid": "1.3.6.1.2.1.31.1.3.1", "nodetype": "row", "class": "objecttype", "maxaccess": "not-accessible", "augmention": { "name": "ifTestEntry", "module": "IF-MIB", "object": "ifEntry" } }, "ifTestId": { "name": "ifTestId", "oid": "1.3.6.1.2.1.31.1.3.1.1", "nodetype": "column", "class": "objecttype", "syntax": { "type": "TestAndIncr", "class": "type" }, "maxaccess": "read-write" }, ... }In general, converted MIBs capture all aspects of original (ASN.1) MIB contentsand layout. The snippet above is just a partial example, but here is thecompleteIF-MIB.jsonfile.
Besides one-to-one MIB conversion, PySMI library can produce JSON index tofacilitate fast MIB information lookup across large collection of MIB files.For example, JSON index forIP-MIB.json,TCP-MIB.json andUDP-MIB.jsonmodules would keep information like this:
{ "compliance": { "1.3.6.1.2.1.48.2.1.1": [ "IP-MIB" ], "1.3.6.1.2.1.49.2.1.1": [ "TCP-MIB" ], "1.3.6.1.2.1.50.2.1.1": [ "UDP-MIB" ] }, "identity": { "1.3.6.1.2.1.48": [ "IP-MIB" ], "1.3.6.1.2.1.49": [ "TCP-MIB" ], "1.3.6.1.2.1.50": [ "UDP-MIB" ] }, "oids": { "1.3.6.1.2.1.4": [ "IP-MIB" ], "1.3.6.1.2.1.5": [ "IP-MIB" ], "1.3.6.1.2.1.6": [ "TCP-MIB" ], "1.3.6.1.2.1.7": [ "UDP-MIB" ], "1.3.6.1.2.1.49": [ "TCP-MIB" ], "1.3.6.1.2.1.50": [ "UDP-MIB" ] } }With this example,compliance andidentity keys point toMODULE-COMPLIANCE andMODULE-IDENTITY MIB objects,oidslist top-level OIDs branches defined in MIB modules. Full indexbuild over thousands of MIBs could be seenhere.
The PySMI library can automatically fetch required MIBs from HTTP, FTP sitesor local directories. You could configure any MIB source available to you (includinghttp://mibs.snmplabs.com/asn1/) for that purpose.
The pysmi package is distributed under terms and conditions of 2-clauseBSDlicense. Source code is freelyavailable as a GitHubrepo.
You couldpip install pysmi or download it fromPyPI.
If something does not work as expected,open an issue at GitHub orpost your questionon Stack Overflow.
Copyright (c) 2015-2020,Ilya Etingof.All rights reserved.
About
SNMP MIB parser
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.