Loading uncompiled MIB files.
See original GitHub issueI’m stumped on what I would think would be a simple task. The sample script “SNMP MIB browser” gives every indication that compiler.addMibCompiler(mibBuilder, sources=['/usr/share/snmp/mibs'])
adds a MIB compiler to load uncompiled MIBs and that mibBuilder.addMibSources(builder.DirMibSource('/opt/pysnmp_mibs'))
is to add a source containing pre-compiled MIBs.
#!/usr/bin/env python
from pysnmp import debug
from pysnmp.smi import builder, view, compiler, rfc1902, error
def main():
# debug.setLogger(debug.Debug('all'))
mibBuilder = builder.MibBuilder()
compiler.addMibCompiler(mibBuilder, sources = ['file:///home/user/python-udp/MIBs', ])
mibBuilder.loadModules('SNMPv2-SMI')
mibBuilder.loadModules('SNMPv2-TC')
mibBuilder.loadModules('INET-ADDRESS-MIB')
mibBuilder.loadModules('IANAifType-MIB')
mibViewController = view.MibViewController(mibBuilder)
modName = mibViewController.getFirstModuleName()
while 1:
if modName: print(modName)
try:
modName = mibViewController.getNextModuleName(modName)
except error.SmiError:
break
return
if __name__ == '__main__':
main()
The loadModules()
all work until the one to load IANAifType-MIB
which is the first one which isn’t included in pysnmp itself. At no point does it give any indication that it’s looking in the directory I specified. I’ve tried numerous variations on the theme but cannot find anything which works. Is there a concise code snippet for loading uncompiled MIBs? Thanks in advance.
Traceback (most recent call last):
File "./loadmib.py", line 24, in <module>
main()
File "./loadmib.py", line 12, in main
mibBuilder.loadModules('IANAifType-MIB')
File "/home/user/python-udp/venv/lib/python2.7/site-packages/pysnmp/smi/builder.py", line 388, in loadModules
raise error.MibNotFoundError('%s compilation error(s): %s' % (modName, errs))
pysnmp.smi.error.MibNotFoundError: IANAifType-MIB compilation error(s): missingcaused by <class 'pysnmp.smi.error.MibNotFoundError'>: MIB file "IANAifType-MIB.py[co]" not found in search path (DirMibSource('/home/user/python-udp/venv/lib/python2.7/site-packages/pysnmp/smi/mibs'), DirMibSource('/home/user/python-udp/venv/lib/python2.7/site-packages/pysnmp/smi/mibs/instances'), DirMibSource('pysnmp_mibs'), DirMibSource('/home/user/.pysnmp/mibs'))caused by <type 'exceptions.IOError'>: [Errno 2] No suitable module found: 'IANAifType-MIB'
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Uncompiled MIB problem...
I tried to load the file as is using the MIB browser that comes with OpManager 5.6; however, it does not work. I...
Read more >Loading Compiled MIBs - WebNMS
WebNMS SNMP API allows loading of compiled MIB files. The compiled MIB files reduce the loading time considerably when compared to direct loading....
Read more >a MIB Compiler supporting SMIv1 and SMIv2
This module can be use to compile MIBs (recursively or not) or load already compiled MIBs for later use. Some tasks can be...
Read more >Managing MIB files - IBM
Compiling a MIB file. You can compile Management Information Base (MIB) files that are located on the IBM Flex System Manager. Loading MIB...
Read more >MIB File Won't Import/Compile - ScienceLogic Support
In some cases, the platform administrator may be able to fix certain issues themselves, but the vendor should make their MIB files compatible ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Your code seems correct and it works for me. Try adding some
pysmi
debugging:To see the search process:
BTW, if you add this URL to the MIBs repo, all your MIBs would be resolved:
Do you also have the
SNMPv2-SMI
MIB in your local collection?Generally, to compile a MIB you have to have all the MIBs it imports (and the MIBs they import and so forth). In other words, you have to have all the MIBs in the dependency chain in uncompiled form.