etingof / pysmi Goto Github PK
View Code? Open in Web Editor NEWSNMP MIB parser
Home Page: http://snmplabs.com/pysmi/
License: BSD 2-Clause "Simplified" License
SNMP MIB parser
Home Page: http://snmplabs.com/pysmi/
License: BSD 2-Clause "Simplified" License
Hi,
I have an issue with the mibdump.py too where it fails to return something non-zero if, for example, the mibfile
file was not found or the --mib-source
directory does not exist.
It's important for me because I use it in my build system and want to detect errors at the right spot.
codegen/pysnmp.py
Can generate python script with more than 255 arguments, which make it not working.
This happened to me on ObjectGroup().setObjects() call. But it can happen on other setObjects() calls as well.
Worked around in my case by editing the generated .py file to assign the large tuple directly to ObjectGroup.objects, which takes a tuple and happened to be public member.
RARITAN-PX2-PDU2-MIB.txt
Attached is the MIB file that would cause problem. Line 71 of generated .py contains > 255 arguments.
Hi,
Using a command prompt with Windows 10, with mibdump.py and MAV3-MIB.mib being in the same folder (C:/sandbox), i am running the following command :
C:\sandbox>mibdump.py MAV3-MIB.mib
It results in the following :
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@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: C:\Users\SESA78282\PySNMP Configuration\mibs
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, 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: MAV3-MIB
Destination format: pysnmp
Custom destination template: None
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: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs:
Missing source MIBs: MAV3-MIB
Ignored MIBs:
Failed MIBs:
Could you please help understanding why the MIB appears as missing ?
Thanks
F
Say you have an MIB in source form, e.g. VOGON-POEM-MIB
. It has dependencies that are already available in compiled form but not (currently) in source form, e.g. SNMPv2-SMI.py
since that's bundled with PySNMP.
Create a MibCompiler
and addSource
such that only the first MIB can be found in source form. Then addSearchers
such that the dependencies can be found in compiled form.
MibCompiler.compile
will then fail because it will only check the searchers if the sources for the dependencies are also available.
This makes it hard to use the precompiled files in pysnmp.smi.mibs
. No combination of searchers and borrowers will fix this situation as far as I can tell.
This may be working as intended or I may be misunderstanding something.
The test suite generates this error (3 of 3) when run against the latest version of pysnmp available in the FreeBSD ports tree (4.3.2), but test-requirements.txt does not stipulate a minimum version. This is reproducible with Python version 2.7.15, 3.4.8, 3.5.5, and 3.6.5, and shown here with the latter.
======================================================================
ERROR: testObjectTypeSyntax (test_objecttype_smiv2_pysnmp.ObjectTypeWithStringSizeConstraintTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/wrkdirs/usr/ports/net-mgmt/py-pysmi/work-py36/pysmi-0.3.0/tests/test_objecttype_smiv2_pysnmp.py", line 326, in setUp
exec(codeobj, self.ctx, self.ctx)
File "test", line 7, in <module>
File "/usr/local/lib/python3.6/site-packages/pysnmp/proto/rfc1902.py", line 201, in subtype
self, value, implicitTag, explicitTag, subtypeSpec
TypeError: subtype() takes from 1 to 2 positional arguments but 5 were given
find . -iname '*.py' | xargs -P 4 -I{} python -Wall -m py_compile {}
./pysmi/codegen/intermediate.py:988: DeprecationWarning: invalid escape sequence \s
self.textFilter = kwargs.get('textFilter') or (lambda symbol, text: re.sub('\s+', ' ', text))
Hi @etingof, thank you for this outstanding module and all the work you've done, it is really awesome.
I'm trying to use pysmi to write my own converter to very custom text file format. I've looked through the pysnmp.py file, but these 1 thousand lines is really hard to rewrite to have something workable. Is there any chance that you provide some small and very basic template/example of AbstractCodeGen child class implementation so one could have at least some starting point please?
I would be very appreciate if this is possible.
Thank you in advance,
Dmitry
Use mibdump.py to convert PAN-COMMON
i try this
mibdump.py --destination-format json PAN-COMMON
and the mistake is
Failed MIBs: PAN-COMMON (Duplicate symbol found: index at MIB PAN-COMMON)
how to solve it
Json codegen does not output when datatypes are table,scalar,row,column object.
Having this information inside of the object would be useful when deciding whether or not to use a bulk get or single get.
I would expect to see something like scalar/table/row etc like in the PYSNMP output format
ifNumber = MibScalar((1, 3, 6, 1, 2, 1, 2, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ifNumber.setStatus('current')
ifTableLastChange = MibScalar((1, 3, 6, 1, 2, 1, 31, 1, 5), TimeTicks()).setMaxAccess("readonly")
if mibBuilder.loadTexts: ifTableLastChange.setStatus('current')
ifTable = MibTable((1, 3, 6, 1, 2, 1, 2, 2), )
ifEntry = MibTableRow((1, 3, 6, 1, 2, 1, 2, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
Example below for IF-MIB
"ifNumber": {
"name": "ifNumber",
"oid": "1.3.6.1.2.1.2.1",
"class": "objecttype",
"syntax": {
"type": "Integer32",
"class": "type"
},
"maxaccess": "read-only",
"status": "current"
},
"ifTableLastChange": {
"name": "ifTableLastChange",
"oid": "1.3.6.1.2.1.31.1.5",
"class": "objecttype",
"syntax": {
"type": "TimeTicks",
"class": "type"
},
"maxaccess": "read-only",
"status": "current"
},
"ifTable": {
"name": "ifTable",
"oid": "1.3.6.1.2.1.2.2",
"class": "objecttype",
"maxaccess": "not-accessible",
"status": "current"
},
"ifEntry": {
"name": "ifEntry",
"oid": "1.3.6.1.2.1.2.2.1",
"class": "objecttype",
"maxaccess": "not-accessible",
"indices": [
{
"module": "IF-MIB",
"object": "ifIndex"
}
],
"status": "current"
},
my pysmi version is 0.3.4
the error code is in jsondoc.py
method: genCode(self, ast, symbolTable, **kwargs)
for sym in self.symbolTable[self.moduleName[0]]['_symtable_order']: if sym not in self._out: raise error.PySmiCodegenError('No generated code for symbol %s' % sym)
the sym is nodeName that has been trans,but the name in self.out is not
so the error happened
Hi,
Thanks for providing this tool.
I'm trying to use pysmi (version-0.3.4) to compile our project's MIBS (Its collection of customized and standard MIBS). While doing so I'm facing compilation errors for some of the customized as well as standard mibs. I just want to ignore those errors and proceed with compiled py file generation, for that I tried --ignore-errors flag with mibdump.py but it seems there is no impact of this flag (I might be using it wrongly..)
Following is what I am trying:
python mibdump.py --generate-mib-texts --destination-format pysnmp --mib-source /corp/sta/projects/leos/mibs/04-18-00-0027/standard --destination-directory /home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard --mib-stub "" --ignore-errors --debug compiler IEEE8021X-PAE-MIB
2020-10-09 03:49:03,629 pysmi: running pysmi version 0.3.3
2020-10-09 03:49:03,630 pysmi: debug category 'compiler' enabled
Source MIB repositories: /corp/sta/projects/leos/mibs/04-18-00-0027/standard
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/fulltexts/@mib@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: /home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard
MIBs excluded from code generation:
MIBs to compile: IEEE8021X-PAE-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: yes
Keep original texts layout: no
Try various file names while searching for MIB module: yes
2020-10-09 03:49:03,821 pysmi: current MIB source(s): FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:03,822 pysmi: current compiled MIBs location(s): PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}, PyPackageSearcher{"pysnmp.smi.mibs"}, PyPackageSearcher{"pysnmp_mibs"}, StubSearcher
2020-10-09 03:49:03,822 pysmi: current MIB borrower(s): PyFileBorrower{http://mibs.snmplabs.com:80/pysnmp/notexts/@mib@, genTexts=False, exts=['.py']}, PyFileBorrower{http://mibs.snmplabs.com:80/pysnmp/fulltexts/@mib@, genTexts=True, exts=['.py']}
2020-10-09 03:49:03,823 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,066 pysmi: IEEE8021X-PAE-MIB (IEEE8021X-PAE-MIB) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/IEEE8021X-PAE-MIB.my, immediate dependencies: IEEE8021-SECY-MIB, IF-MIB, SNMP-FRAMEWORK-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,066 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,183 pysmi: IEEE8021-SECY-MIB (IEEE8021-SECY-MIB) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/IEEE8021-SECY-MIB.my, immediate dependencies: IF-MIB, SNMP-FRAMEWORK-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,183 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,264 pysmi: IF-MIB (IF-MIB) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/IF-MIB.my, immediate dependencies: IANAifType-MIB, SNMPv2-CONF, SNMPv2-MIB, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,264 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,283 pysmi: SNMP-FRAMEWORK-MIB (SNMP-FRAMEWORK-MIB) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/SNMP-FRAMEWORK-MIB.my, immediate dependencies: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,283 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,292 pysmi: SNMPv2-CONF (SNMPv2-CONF) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/SNMPv2-CONF.my, immediate dependencies: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,293 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,304 pysmi: SNMPv2-SMI (SNMPv2-SMI) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/SNMPv2-SMI.my, immediate dependencies: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,305 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,322 pysmi: SNMPv2-TC (SNMPv2-TC) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/SNMPv2-TC.my, immediate dependencies: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,322 pysmi: MIB IF-MIB already parsed
2020-10-09 03:49:04,323 pysmi: MIB SNMP-FRAMEWORK-MIB already parsed
2020-10-09 03:49:04,323 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,323 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,324 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,324 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,346 pysmi: IANAifType-MIB (IANAifType-MIB) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/IANAifType-MIB.my, immediate dependencies: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,346 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,346 pysmi: trying source FileReader{"/corp/sta/projects/leos/mibs/04-18-00-0027/standard"}
2020-10-09 03:49:04,394 pysmi: SNMPv2-MIB (SNMPv2-MIB) read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/SNMPv2-MIB.my, immediate dependencies: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
2020-10-09 03:49:04,394 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,394 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,395 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,395 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,396 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,396 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,396 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,397 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,397 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,397 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,397 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,398 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,398 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,398 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,399 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,399 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,399 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,400 pysmi: MIB SNMPv2-CONF already parsed
2020-10-09 03:49:04,400 pysmi: MIB SNMPv2-SMI already parsed
2020-10-09 03:49:04,400 pysmi: MIB SNMPv2-TC already parsed
2020-10-09 03:49:04,401 pysmi: MIBs analyzed 9, MIBs failed 0
2020-10-09 03:49:04,401 pysmi: checking if SNMPv2-CONF requires updating
2020-10-09 03:49:04,405 pysmi: will be using existing compiled MIB SNMPv2-CONF found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,405 pysmi: checking if IF-MIB requires updating
2020-10-09 03:49:04,410 pysmi: will be using existing compiled MIB IF-MIB found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,411 pysmi: checking if SNMPv2-MIB requires updating
2020-10-09 03:49:04,412 pysmi: will be using existing compiled MIB SNMPv2-MIB found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,412 pysmi: checking if SNMP-FRAMEWORK-MIB requires updating
2020-10-09 03:49:04,414 pysmi: will be using existing compiled MIB SNMP-FRAMEWORK-MIB found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,414 pysmi: checking if SNMPv2-SMI requires updating
2020-10-09 03:49:04,416 pysmi: will be using existing compiled MIB SNMPv2-SMI found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,416 pysmi: checking if IANAifType-MIB requires updating
2020-10-09 03:49:04,417 pysmi: will be using existing compiled MIB IANAifType-MIB found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,417 pysmi: checking if IEEE8021X-PAE-MIB requires updating
2020-10-09 03:49:04,418 pysmi: no compiled MIB IEEE8021X-PAE-MIB available through PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,418 pysmi: no compiled MIB IEEE8021X-PAE-MIB available through PyPackageSearcher{"pysnmp.smi.mibs"}
2020-10-09 03:49:04,419 pysmi: no compiled MIB IEEE8021X-PAE-MIB available through PyPackageSearcher{"pysnmp_mibs"}
2020-10-09 03:49:04,419 pysmi: no compiled MIB IEEE8021X-PAE-MIB available through StubSearcher
2020-10-09 03:49:04,419 pysmi: no suitable compiled MIB IEEE8021X-PAE-MIB found anywhere
2020-10-09 03:49:04,419 pysmi: checking if SNMPv2-TC requires updating
2020-10-09 03:49:04,420 pysmi: will be using existing compiled MIB SNMPv2-TC found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,421 pysmi: checking if IEEE8021-SECY-MIB requires updating
2020-10-09 03:49:04,422 pysmi: will be using existing compiled MIB IEEE8021-SECY-MIB found by PyFileSearcher{"/home/dsaxena/.pysnmp/04-18-00-0027/mibs/standard"}
2020-10-09 03:49:04,422 pysmi: MIBs parsed 1, MIBs failed 0
2020-10-09 03:49:04,422 pysmi: compiling IEEE8021X-PAE-MIB read from file:///corp/sta/projects/leos/mibs/04-18-00-0027/standard/IEEE8021X-PAE-MIB.my
2020-10-09 03:49:04,451 pysmi: error from <pysmi.codegen.pysnmp.PySnmpCodeGen object at 0x7fab62a345d0>: no symbol "Unsigned32" in module "SNMPv2-SMI" at MIB IEEE8021X-PAE-MIB
2020-10-09 03:49:04,451 pysmi: MIBs built 0, MIBs failed 1
2020-10-09 03:49:04,451 pysmi: trying to borrow IEEE8021X-PAE-MIB from PyFileBorrower{http://mibs.snmplabs.com:80/pysnmp/notexts/@mib@, genTexts=False, exts=['.py']}
2020-10-09 03:49:04,451 pysmi: error from PyFileBorrower{http://mibs.snmplabs.com:80/pysnmp/notexts/@mib@, genTexts=False, exts=['.py']}:
2020-10-09 03:49:04,452 pysmi: trying to borrow IEEE8021X-PAE-MIB from PyFileBorrower{http://mibs.snmplabs.com:80/pysnmp/fulltexts/@mib@, genTexts=True, exts=['.py']}
2020-10-09 03:51:27,541 pysmi: error from PyFileBorrower{http://mibs.snmplabs.com:80/pysnmp/fulltexts/@mib@, genTexts=True, exts=['.py']}: source MIB IEEE8021X-PAE-MIB not found
2020-10-09 03:51:27,542 pysmi: MIBs available for borrowing 0, MIBs failed 1
2020-10-09 03:51:27,542 pysmi: MIBs built 0, MIBs failed 1
2020-10-09 03:51:27,542 pysmi: proceeding with built MIBs , failed MIBs IEEE8021X-PAE-MIB
2020-10-09 03:51:27,542 pysmi: MIBs modified:
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs: IANAifType-MIB, IEEE8021-SECY-MIB, IF-MIB, SNMP-FRAMEWORK-MIB, SNMPv2-CONF, SNMPv2-MIB, SNMPv2-SMI, SNMPv2-TC
Missing source MIBs:
Ignored MIBs:
Failed MIBs: IEEE8021X-PAE-MIB (no symbol "Unsigned32" in module "SNMPv2-SMI" at MIB IEEE8021X-PAE-MIB)
I'm planning to use pysnmp for snmp operations (which internally uses pysmi) but can't proceed if these errors exist. Please suggest how to resolve this. Earlier I was using netsnmp linux commands which ignores such errors but has performance issue as perform compilation at run time on each and every snmp operation call and stores in memory (what I could understood) so just want to opt better solution.
Hello friends.
I need to convert a local file MIB to the format json. How can I do this using pysmi? I didn't quite understand the example commands.
The file that needs to be translated is attached. The file of MIB is located in the python script folder.
The result json file must be in the python script folder.
Please give an example of the command for mibdump.py or example of a program that will do this for my MIB file.
IDE Pycharm
MIB file you can download here https://www.shtyl.ru/support/download/software/mib-fajl-dlya-ustanovok-ehlektropitaniya/
Just in case, I also attach the MIB
Shtyl_MIB_18_v367.zip
If host running mibdump (linux) is behind a proxy server with evoirment variables set (http_proxy; https_proxy; ftp_proxy; ftps_proxy) additional mibs are not downloaded.
$ mibdump.py --generate-mib-texts --destination-format json IF-MIB
Source 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-TM
MIBs to compile: IF-MIB
Destination format: json
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: no (optimization level no)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: yes
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs:
Missing source MIBs: IF-MIB
Ignored MIBs:
Failed MIBs:
objectType = ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), 'Linux i386')
objectType.resolveWithMib(MibViewController)
print(str(objectType))
The error is :
AttributeError: type object 'MibViewController' has no attribute 'mibBuilder'
I just followed the example,but it failed.
Is it a problem with my enviroment?
from pysnmp.proto.rfc1902 import Integer32
from pysnmp.smi.rfc1902 import ObjectIdentity, ObjectType
from pysnmp.hlapi import *
from pysnmp.smi.view import *
This is the MIB entry where I am getting error
hm2DHCPServerPoolFlags = MibTableColumn((1, 3, 6, 1, 4, 1, 248, 11, 91, 1, 1, 1, 5, 1, 5), Bits().clone(namedValues=NamedValues(("interface", 0), ("mac", 1), ("gateway", 2), ("clientid", 3), ("remoteid", 4), ("circuitid", 5), ("dynamic", 6), ("vlanid", 7)))).setMaxAccess("readcreate")
The error which I am getting is
hm2DHCPServerPoolFlags = MibTableColumn((1, 3, 6, 1, 4, 1, 248, 11, 91, 1, 1, 1, 5, 1, 5), Bits().clone(namedValues=NamedValues(("interface", 0), ("mac", 1), ("gateway", 2), ("clientid", 3), ("remoteid", 4), ("circuitid", 5), ("dynamic", 6), ("vlanid", 7)))).setMaxAccess("readcreate")
File "C:\Python27\lib\site-packages\pysnmp\proto\rfc1902.py", line 605, in __init__
OctetString.__init__(self, value, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'namedValues'
On some debugging I found that in rfc 1902.py for Bits class the init is like
def __init__(self, value=univ.noValue, **kwargs):
if 'namedValues' not in kwargs:
kwargs['namedValues'] = self.namedValues
OctetString.__init__(self, value, **kwargs)
So its calling octet string constructer which would be basically init of univ.OctetString
which does not have namedValue as keyword args, hence the error
def __init__(self, value=noValue, tagSet=None, subtypeSpec=None,
encoding=None, binValue=noValue, hexValue=noValue):
I am trying to compile HP ILO node MIBs and generate the Json file.
The tool generates wrong OIDs for the traps
generated by Tool::
"name": "cpqiScsiLinkUp",
"oid": "1.3.6.1.4.1.2320.169001",
Expected :
"name": "cpqiScsiLinkUp",
"oid": "1.3.6.1.4.1.232.0.169001",
cpqiscsi.zip
Hello,
I try convert mib file to json with mibdump, but file contains multiple MODULE-IDENTITY (ex.: http://www.circitor.fr/Mibs/Mib/R/RAISECOM-SYSTEM-MIB.mib) and script ends with error: Failed MIBs: RAISECOM-SYSTEM-MIB (Duplicate module identity at MIB RAISECOM-SYSTEM-MIB).
Is there any option to fix this trouble?
Use mibdump.py
to convert LSI-MegaRAID-SAS-MIB.
At first,I use the command
mibdump.py LSI-MegaRAID-SAS-MIB
The mistake is Duplicate symbol found: bbuFRU at MIB LSI-MegaRAID-SAS-MIB.
So I download the file, changed it to make it not a duplicate part.Then I use this command
mibdump.py --mib-source http://192.168.1.170/ LSI-MegaRAID-SAS1-MIB
That's why I can run the locally modified file (LSI-MegaRAID-SAS-MIB).
The new mistake appeared no module "SNMPv2-SMI" in symbolTable at MIB LSI-MegaRAID-SAS-MIB.
I listened to some suggestions, use the command
mibdump.py --mib-source=http://mibs.snmplabs.com/asn1 LSI-MegaRAID-SAS1-MIB
It was not go, the mistake of Missing source MIBs: LSI-MegaRAID-SAS1-MIB.
I am trying to compile attached MIB(renamed extension to .txt) and its failing with following error
Failed MIBs: HM2-CAM-MGMT-MIB (no symbol "Unsigned32" in module "SNMPv2-SMI" at MIB HM2-CAM-MGMT-MIB)
On some debugging I found that issue is with following entry
hm2CamClientServerPort OBJECT-TYPE
SYNTAX InetPortNumber
MAX-ACCESS read-create
STATUS current
DESCRIPTION
"The port number of the CAM authentication server."
DEFVAL { 389 }
::= { hm2CamClientServerAddrEntry 4 }
InetPortNumber
is part of INET-ADDRESS-MIB which is standard mib I believe.
I'm in need of converting the error log of my aplication to a MIB file, don't need be plain text, can be json, or strings. Can I do this with pysmi?
I see that the last release was in April 2019. Please let me know if the project is still maintained, stable and will there be any future releases? Or is it deprecated?
(Not sure if this issue should be filed here or under the pysnmp project)
I am experiencing problems when trying to use pysnmp with the ENTITY-MIB. It seems pysmi is building an incorrect .py file for the ENTITY-MIB.
To reproduce, make sure that the .py for ENTITY-MIB has not been generated before. Place the ENTITY-MIB, and its requirements in a folder. I downloaded all of them from http://mibs.snmplabs.com/asn1/:
wget http://mibs.snmplabs.com/asn1/ENTITY-MIB
wget http://mibs.snmplabs.com/asn1/SNMP-FRAMEWORK-MIB
wget http://mibs.snmplabs.com/asn1/SNMPv2-CONF
wget http://mibs.snmplabs.com/asn1/SNMPv2-SMI
wget http://mibs.snmplabs.com/asn1/SNMPv2-TC
Now, try to compile and load the mib:
from pysnmp.smi import builder, view, compiler
import pysnmp
mibBuilder = pysnmp.smi.builder.MibBuilder()
compiler.addMibCompiler(mibBuilder, sources=("/home",))
com = mibBuilder.getMibCompiler()
com.compile("ENTITY-MIB")
mibBuilder.loadModule("ENTITY-MIB")
Which, to me, raises an exception:
MibLoadError: MIB module "/root/.pysnmp/mibs/ENTITY-MIB.py" load error: ['Traceback (most recent call last):\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 331, in loadModule\n exec (modData, g)\n', ' File "<string>", line 127\n', " entConfigChange = NotificationType((1, 3, 6, 1, 2, 1, 47, 2, 0, 1))if mibBuilder.loadTexts: entConfigChange.setStatus('current')\n",
The reason for it is a missing break line before the if statement. Adding it manually solves the problem.
I hope you can reproduce the problem.
When I run this command:
C:\Users\kc\AppData\Local\Programs\Python\Python36-32\Scripts>pip install -e git+https://github.com/etingof/pysmi.git
egg=pysmi
I get this error:
Obtaining pysmi from git+https://github.com/etingof/pysmi.git#egg=pysmi
Cloning https://github.com/etingof/pysmi.git to c:\users\kc\appdata\local\programs\python\python36-32\scripts\src\p
smi
fatal: unable to access 'https://github.com/etingof/pysmi.git/': SSL certificate problem: unable to get local issuer cetificate
Command "git clone -q https://github.com/etingof/pysmi.git C:\Users\kc\AppData\Local\Programs\Python\Python36-32\Scri
ts\src\pysmi" failed with error code 128 in None
The test suite generates this error (2 of 3) when run against the latest version of pysnmp available in the FreeBSD ports tree (4.3.2), but test-requirements.txt
does not stipulate a minimum version. This is reproducible with Python version 2.7.15, 3.4.8, 3.5.5, and 3.6.5, and shown here with the latter.
======================================================================
ERROR: testObjectTypeSyntax (test_objecttype_smiv2_pysnmp.ObjectTypeStringDefaultTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/wrkdirs/usr/ports/net-mgmt/py-pysmi/work-py36/pysmi-0.3.0/tests/test_objecttype_smiv2_pysnmp.py", line 218, in setUp
exec(codeobj, self.ctx, self.ctx)
File "test", line 7, in <module>
File "/usr/local/lib/python3.6/site-packages/pysnmp/proto/rfc1902.py", line 195, in clone
self, value, tagSet, subtypeSpec, encoding, binValue, hexValue
TypeError: clone() takes from 1 to 2 positional arguments but 7 were given
I installed pysmi from the master branch as following:
mibdump.py --destination-directory=/destination/path A3COM00xx-BRIDGE-EXT-MIB
which produces following output:
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@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: /destination/path
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, 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, TRAN
SPORT-ADDRESS-MIB
MIBs to compile: A3COM00xx-BRIDGE-EXT-MIB
Destination format: pysnmp
Custom destination template: None
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: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Traceback (most recent call last):
File "mibdump.py", line 368, in <module>
ignoreErrors=ignoreErrorsFlag)
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/pysmi-0.4.0-py3.6.egg/pysmi/compiler.py
", line 358, in compile
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/pysmi-0.4.0-py3.6.egg/pysmi/codegen/pys
nmp.py", line 153, in genCode
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/jinja2/environment.py", line 830, in ge
t_template
return self._load_template(name, self.make_globals(globals))
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _l
oad_template
template = self.loader.load(self, name, globals)
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/jinja2/loaders.py", line 113, in load
source, filename, uptodate = self.get_source(environment, name)
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/jinja2/loaders.py", line 171, in get_so
urce
f = open_if_exists(filename)
File "/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-packages/jinja2/utils.py", line 154, in open_if_
exists
return open(filename, mode)
NotADirectoryError: [Errno 20] Not a directory: '/home/faysal/PycharmProjects/pysmi/venv/lib/python3.6/site-package
s/pysmi-0.4.0-py3.6.egg/pysmi/codegen/templates/pysnmp/mib-definitions.j2'
output from "mibdump.py --version"
SNMP SMI/MIB library version 0.4.0, written by Ilya Etingof <[email protected]>
Python interpreter: 3.6.7 (default, Oct 22 2018, 11:32:17)
Looks like mibdump.py conversion to json has trouble working with bit types.
Can recreate with this:
mibdump.py --generate-mib-texts --destination-format json DOCS-IF3-MIB
I get the following error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/mibdump.py", line 302, in
ignoreErrors=ignoreErrorsFlag))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pysmi/compiler.py", line 333, in compile
genTexts=options.get('genTexts')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pysmi/codegen/jsondoc.py", line 735, in genCode
self.handlersTable[declr[0]](self, self.prepData(declr[1:]))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pysmi/codegen/jsondoc.py", line 116, in prepData
self.handlersTable[el[0]](self, self.prepData(el[1:]))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pysmi/codegen/jsondoc.py", line 669, in genTypeDeclarationRHS
outDict['type'] = attrs['type']
KeyError: 'type'
The test suite generates this error (1 of 3) when run against the latest version of pysnmp available in the FreeBSD ports tree (4.3.2), but test-requirements.txt
does not stipulate a minimum version. This is reproducible with Python version 2.7.15, 3.4.8, 3.5.5, and 3.6.5, and shown here with the latter.
======================================================================
ERROR: testObjectTypeSyntax (test_objecttype_smiv2_pysnmp.ObjectTypeBitsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/wrkdirs/usr/ports/net-mgmt/py-pysmi/work-py36/pysmi-0.3.0/tests/test_objecttype_smiv2_pysnmp.py", line 361, in setUp
exec(codeobj, self.ctx, self.ctx)
File "test", line 7, in <module>
File "/usr/local/lib/python3.6/site-packages/pysnmp/proto/rfc1902.py", line 606, in __init__
self, value, tagSet, subtypeSpec, encoding, binValue, hexValue
TypeError: __init__() takes from 1 to 2 positional arguments but 7 were given
Hi, wondering about the state of JSON support. Noticed it's not in v0.0.7, so pulling off of master branch. Trying to generate JSON files from local MIBs but am not having success. The index gets generated but there's no content in it. Using the following code:
def transform_mibs_to_json(self, specific_mibs=None, exclude_mibs=['test-mib.my']):
mib_names = []
if specific_mibs is None:
for filename in os.listdir(self.local_mib_dir):
try: filename.rindex('.my', -3)
except: continue
mib_names.append(filename)
else:
mib_names = specific_mibs.copy()
try:
mib_compiler = MibCompiler(
SmiV1CompatParser(),
JsonCodeGen(),
FileWriter(self.local_json_dir).setOptions(suffix='.json')
)
mib_compiler.addSources(FileReader(self.local_mib_dir, recursive=True))
mib_stubs = JsonCodeGen.baseMibs
searchers = [AnyFileSearcher(self.local_json_dir).setOptions(exts=['.json']), StubSearcher(*mib_stubs)]
mib_compiler.addSearchers(*searchers)
if not os.path.isdir(self.local_json_dir):
os.makedirs(self.local_json_dir)
processed = mib_compiler.compile(
*mib_names,
**dict(
noDeps=False,
rebuild=True,
genTexts=True,
writeMibs=True,
ignoreErrors=False
)
)
mib_compiler.buildIndex(
processed,
ignoreErrors=False
)
except error.PySmiError:
sys.stderr.write('ERROR: %s\n' % sys.exc_info()[1])
sys.exit(-1)
See anything wrong in usage? Will try and submit a fix if it's a bug.
Any pointers or thoughts?
I get
error from <pysmi.codegen.pysnmp.PySnmpCodeGen object at 0xffff8fe13110>: Jinja template rendering error: 'collections.OrderedDict object' has no attribute 'default' at MIB DOCS-IF3-MIB
when compiling DOCS-IF3-MIB from http://mibs.cablelabs.com/MIBs/DOCSIS/Archive-PreviousVersions/DOCS-IF3-MIB-2020-06-25.txt
I don't see any serious issues when checking with https://www.simpleweb.org/ietf/mibs/validate/ and using a quite old pysmi (0.3.4) it works also fine.
let me know if you need more info to help me out.
I have a MIB file provided from the manufacturer that fails when running mibdump.py.
The error I get is:
Failed MIBs: RMB2BBR (Bad grammar near token type MODULE_IDENTITY, value MODULE-IDENTITY at MIB RMB2BBR, line 24)
Can you help me resolve this?
Here is the offending file
RMB2BBR.txt
Will try to dig through pysmi internals and fix it eventually, wanted to file it regardless. :)
Related to jsondoc.py
2018-04-05 15:40:21,526 pysmi: compiling CISCO-IETF-SCTP-EXT-CAPABILITY read from file:///Users/vinm/PycharmProjects/snmp_v2/mibs/CISCO-IETF-SCTP-EXT-CAPABILITY.my
Traceback (most recent call last):
File "/Users/vinm/PycharmProjects/snmp_v2/snmp_v2.py", line 170, in <module>
snmppop.transform_mibs_to_json()
File "/Users/vinm/PycharmProjects/snmp_v2/snmp_v2.py", line 119, in transform_mibs_to_json
ignoreErrors=True
File "/Users/vinm/PycharmProjects/snmp_v2/venv/lib/python3.6/site-packages/pysmi/compiler.py", line 335, in compile
textFilter=options.get('textFilter')
File "/Users/vinm/PycharmProjects/snmp_v2/venv/lib/python3.6/site-packages/pysmi/codegen/jsondoc.py", line 940, in genCode
self.handlersTable[declr[0]](self, self.prepData(declr[1:]))
File "/Users/vinm/PycharmProjects/snmp_v2/venv/lib/python3.6/site-packages/pysmi/codegen/jsondoc.py", line 95, in prepData
self.handlersTable[el[0]](self, self.prepData(el[1:]))
KeyError: 'PRODUCT-RELEASE'
ftp://ftp.cisco.com/pub/mibs/v2/CISCO-IETF-SCTP-EXT-CAPABILITY.my
What I thought as the older obsolete tool, was able to convert my MIB file to its .py equivalent:
build-pysnmp-mib -o MYMIB.py MYMIB.mib
Whereas, the newer mibdump.py gave an error:
mibdump.py --destination-format=pysnmp --destination-directory=`pwd` ./MYMIB.mib
...
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, 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: MYMIB
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: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs:
Missing source MIBs:
Ignored MIBs:
Failed MIBs: MYMIB (Bad grammar near token type LOWERCASE_IDENTIFIER, value rfnSiemRogueApDetectorTableEntry at MIB MYMIB, line 75)
Is there something wrong in the MIB or in mibdump.py?
Hey!
On Debian, tests are failing with the following error:
======================================================================
ERROR: testObjectTypeSyntax (test_objecttype_smiv2_pysnmp.ObjectTypeBitsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/build/pysmi-0.3.1/tests/test_objecttype_smiv2_pysnmp.py", line 365, in testObjectTypeSyntax
self.ctx['testObjectType'].getSyntax().clone(('set',)), str2octs('@'),
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc1902.py", line 202, in clone
return univ.OctetString.clone(self, *args, **kwargs).setFixedLength(self.getFixedLength())
File "/usr/lib/python2.7/dist-packages/pyasn1/type/base.py", line 349, in clone
return self.__class__(value, **initilaizers)
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc1902.py", line 603, in __new__
Bits = cls.withNamedBits(**kwargs.pop('namedValues'))
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc1902.py", line 642, in withNamedBits
class X(cls):
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc1902.py", line 643, in X
namedValues = cls.namedValues + namedval.NamedValues(*values.items())
File "/usr/lib/python2.7/dist-packages/pyasn1/type/namedval.py", line 166, in __add__
return self.__class__(*tuple(self.items()) + tuple(namedValues.items()))
File "/usr/lib/python2.7/dist-packages/pyasn1/type/namedval.py", line 74, in __init__
raise error.PyAsn1Error('Duplicate name %s' % (name,))
PyAsn1Error: Duplicate name notification
----------------------------------------------------------------------
Ran 108 tests in 6.123s
This happens with PySMI 0.3.1 and PyASN1 0.4.4. Any clue?
Thanks!
Documentation specify that
"Setting destination directory
By default mibdump.py writes pysnmp MIBs into:
$HOME/.pysnmp/mibs (on UNIX)
@HOME@PySNMP ConfigurationMIBs (on Windows)
and JSON files in current working directory.
Use –destination-directory option to change default output directory."
but when using this flag its always over written to the defaults in dstFormat if/elif for pysnmp or json.
my solution (only tested on linux) is to define dtsDirectory = None in defaults
and then have an "if not dstDirectory" in the if/elif for pysnmp or json before setting the defaults
example:
if not dstDirectory:
dstDirectory = os.path.expanduser("~")
if sys.platform[:3] == 'win':
dstDirectory = os.path.join(dstDirectory, 'PySNMP Configuration', 'mibs')
else:
dstDirectory = os.path.join(dstDirectory, '.pysnmp', 'mibs')
I see that in localfile.py the FileReader class does not fill in the oid/oids fields as well as some others listed in the mibinfo.py class. Are there plans to implement this in the future?
Currently the return of FileReader.getData() looks like so
return MibInfo(path='file://%s' % f, file=mibfile, name=mibalias, mtime=mtime), decode(mibData)
I want to easily get ahold of these data fields.
"name": "commonDeviceFeatureKeys",
"oid": "1.3.6.1.4.1.331.1.2.1.1.7",
"class": "objectidentity",
"status": "current"
},
I have used mibdump.py command line tool to generate JSON files but I would like to be able to access this info from a function call. Or generate the JSON without having to open a terminal.
Any help would be appreciated.
I'm getting an error when parsing a certain MIB:
mibdump.py --destination-format=json HUAWEI-MIB
Source MIB repositories: file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@mib@
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/json/notexts/@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-TM
MIBs to compile: HUAWEI-MIB
Destination format: json
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: no (optimization level no)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
Missing source MIBs:
Ignored MIBs:
Failed MIBs: HUAWEI-MIB (No generated code for symbol pysmi_as at MIB HUAWEI-MIB)
It looks like this is caused by 1.3.6.1.4.1.2011.2.36 with descriptor 'as,' which is a python keyword.
It turns out that MIB modules may come concatenated into a single file. Current pysmi logic does not accommodate for that situation.
This MIB seems to compile to pysnmp fine with mibdump.py, however when trying to execute mibBuilder.loadModules('WIENER-CRATE-MIB')
The following error is encountered:
Loading MIB modules... Traceback (most recent call last): File "/Users/name/.local/share/virtualenvs/MPOD-PfZE_iSv/lib/python3.7/site-packages/pysnmp/smi/builder.py", line 344, in loadModule exec(codeObj, g) File "/Users/name/.pysnmp/mibs/WIENER-CRATE-MIB.py", line 233, in <module> snmpCommunityTable = MibTableColumn((1, 3, 6, 1, 4, 1, 19947, 1, 5, 1, 1), ) TypeError: __init__() missing 1 required positional argument: 'syntax'
It looks like the compiler is listing some tables as MibTableColumns. I'm not sure how to fix this. Any help or ideas would be appreciated.
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\pysnmp\smi\builder.py", line 344, in loadModule
exec(codeObj, g)
File "C:\Projects\test_mibs\USHA-MIB.py", line 211, in <module>
upsDevicesTable = MibTable((1, 3, 6, 1, 4, 1, 2468, 1, 2, 1, 1, 9, 2), ).setIndexNames((0, "USHA-MIB", "indexOfDevice"))
AttributeError: 'MibTable' object has no attribute 'setIndexNames'
Mibs were compiled as such:
~/Downloads/mibs$ mibdump.py --destination-format=pysnmp --destination-directory=./../test_mibs ./RFC1628.MIB
Source MIB repositories: /mnt/c/Users/RWeber.OSS/Downloads/mibs, file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@mib@
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: ./../test_mibs
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, 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: RFC1628
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: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs: RFC-1212, RFC-1215, RFC1155-SMI, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, UPS-MIB
Missing source MIBs:
Ignored MIBs:
Failed MIBs:
~/Downloads/mibs$ mibdump.py --destination-format=pysnmp --destination-directory=./../test_mibs ./USHAP-v6.MIB
Source MIB repositories: /mnt/c/Users/RWeber.OSS/Downloads/mibs, file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@mib@
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: ./../test_mibs
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, 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: USHAP-v6
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: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs: RFC-1212, RFC-1215, RFC1155-SMI, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, UPS-MIB, USHA-MIB
Missing source MIBs:
Ignored MIBs:
Failed MIBs:
When running mibdump tool, the output log says few of the mib files were excluded from code generation as below. Can someone please let me know what's the reason behind this exclusion and is there an option to override this behavior?
MIBs excluded from code generation: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI,
RFC1158-MIB, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM
Hi,
I am getting error like:
pysnmp.smi.error.MibNotFoundError: VEEAM compilation error(s): missing; missing; missing; missing; missing; missing; no module "SNMPv2-SMI" in symbolTable at MIB VEEAM-MIB
Repro steps:
Veeam.mib
VEEAM-MIB DEFINITIONS ::= BEGIN
IMPORTS
enterprises
FROM RFC1155-SMI
TRAP-TYPE
FROM RFC-1215
OBJECT-TYPE
FROM RFC-1212
DisplayString
FROM SNMPv2-TC;
veeam OBJECT IDENTIFIER ::= { enterprises 31023 }
products OBJECT IDENTIFIER ::= { veeam 1 }
backup OBJECT IDENTIFIER ::= { products 1 }
traps OBJECT IDENTIFIER ::= { backup 1 }
onBackupJobCompleted TRAP-TYPE
ENTERPRISE traps
VARIABLES { backupJobId, backupJobName, backupJobResult, backupJobComment }
DESCRIPTION
"This trap is sent on backup/replica job completed."
::= 1
onVmBackupCompleted TRAP-TYPE
ENTERPRISE traps
VARIABLES { backupJobName, vmName, sourceHostName, vmBackupResult, vmBackupComment }
DESCRIPTION
"This trap is sent on vm backup/replica completed."
::= 2
onLinuxFLRMountStarted TRAP-TYPE
ENTERPRISE traps
VARIABLES { sessionId, initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime }
DESCRIPTION
"This trap is sent when Multi-OS FLR helper appliance starts."
::= 3
onLinuxFLRCopyToStarted TRAP-TYPE
ENTERPRISE traps
VARIABLES { sessionId, initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime, targetHost, targetDir }
DESCRIPTION
"This trap is sent when Multi-OS FLR file recovery via Copy To operation is initiated."
::= 4
onLinuxFLRToOriginalStarted TRAP-TYPE
ENTERPRISE traps
VARIABLES { sessionId, initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime }
DESCRIPTION
"This trap is sent when Multi-OS FLR file recovery via Restore operation is initiated."
::= 5
onLinuxFLRCopyToFinished TRAP-TYPE
ENTERPRISE traps
VARIABLES { sessionId, initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime, transferStatus, transferTime, transferFileList, notTransferFileList, targetHost, targetDir }
DESCRIPTION
"This trap is sent when Multi-OS FLR file recovery via Copy To operation is completed."
::= 6
onLinuxFLRToOriginalFinished TRAP-TYPE
ENTERPRISE traps
VARIABLES { sessionId, initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime, transferStatus, transferTime, transferFileList, notTransferFileList }
DESCRIPTION
"This trap is sent when Multi-OS FLR file recovery via Restore operation is completed."
::= 7
onWinFLRMountStarted TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmName, vmRestorePointCreationTime, vmRestorePointId, mountServerName }
DESCRIPTION
"This trap is sent when Windows FLR starts to mounts a backup."
::= 8
onWinFLRToOriginalStarted TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime }
DESCRIPTION
"This trap is sent when Windows FLR file recovery via Restore operation is completed."
::= 9
onWinFLRCopyToStarted TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime, targetDir }
DESCRIPTION
"This trap is sent when Windows FLR file recovery via Copy To operation is initiated."
::= 10
onWinFLRToOriginalFinished TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime, transferStatus, transferFileList, notTransferFileList }
DESCRIPTION
"This trap is sent when Windows FLR file recovery via Restore operation is completed."
::= 11
onWinFLRCopyToFinished TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmName, vmRestorePointId, vmRestorePointCreationTime, transferStatus, transferFileList, notTransferFileList, targetDir }
DESCRIPTION
"This trap is sent when Windows FLR file recovery via Copy To operation is completed."
::= 12
onWebDownloadStart TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmRestorePointId, vmName, vmRestorePointCreationTime }
DESCRIPTION
"This trap is sent when 1-Click FLR file download operation is initiated in the Enterprise Manager."
::= 13
onWebDownloadFinished TRAP-TYPE
ENTERPRISE traps
VARIABLES { initiatorName, initiatorSid, vmRestorePointId, vmName, vmRestorePointCreationTime, transferStatus, transferFileList, notTransferFileList }
DESCRIPTION
"This trap is sent when 1-Click FLR file download operation is completed in the Enterprise Manager."
::= 14
backupJobId OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Backup job id"
::= { backup 101 }
backupJobName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Backup job name"
::= { backup 102 }
backupJobResult OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Backup job result"
::= { backup 103 }
backupJobComment OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Backup job comment"
::= { backup 104 }
vmName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"VM name."
::= { backup 105 }
sourceHostName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Source host name"
::= { backup 106 }
vmBackupResult OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"VM backup result"
::= { backup 107 }
vmBackupComment OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"VM backup comment"
::= { backup 108 }
sessionId OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Restore session ID"
::= { backup 109 }
initiatorName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Initiated by"
::= { backup 110 }
initiatorSid OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Initiated by (SID)"
::= { backup 111 }
vmRestorePointId OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Restore point ID"
::= { backup 112 }
vmRestorePointCreationTime OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Restore point creation time"
::= { backup 113 }
targetHost OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Target host"
::= { backup 114 }
targetDir OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Target directory"
::= { backup 115 }
transferStatus OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Restore result"
::= { backup 116 }
transferTime OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Restore time"
::= { backup 117 }
transferFileList OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Restored files"
::= { backup 118 }
notTransferFileList OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Failed to restore"
::= { backup 119 }
mountServerName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"Mount server name"
::= { backup 120 }
END
Tried to verify this mib with online parser, still no clue - should imports be changed?
I'm trying to generate pysnmp compiled MIBs from ASN text files. The text files import some of the standard MIBs that are shipped precompiled with pysnmp/smi e.g. "SNMPv2-SMI". I run into issues when running the mibCompiler.compile() method and it looks like it is trying to generate code for the ASN mibs before it loads the precompiled MIBs from the list of borrowers.
Is there a way to get the precompiled MIBs like "SNMPv2-SMI" that live as a .py in my site-packages folder into the symbolTable of the mibCompiler before the code gen process is run on each of the custom text MIBs? Or does the MibCompiler require that the ASN sources for all dependencies are present?
Hi,
So currently I am using the following code to save the parsed JSON info to some file.
mibCompiler = MibCompiler(
SmiStarParser(), JsonCodeGen(), PyFileWriter(FILENAME)
)
And at the same time to extract the information corresponding to each OID in this file, I am using pysnmp. But, this pipeline of
parsing JSON > Dumping JSON to file > Reading JSON > Extracting OID info using pysnmp
is too slow and inefficient. So is there a way, I can skip the file writing-reading part and directly send the parsed JSON to my oid extractor function?
Also, what is pysnmp's functional equivalent to parse the given MIB
Any help is much appreciated. Thanks
Dear
any chance to have your mib parser in nodejs and typescript or javascript?
Best Regards
Youssef
As per question above, I want the JSON conversion of some foundation mibs such as rfc1213 and entity-mib. I just want the oids really, and I could hard code them, but I prefer to do it from the mibs.
The tool ignores these mibs but I can't find reasons why in the doco.
Am new to SNMP as a whole... so apologies if this is a n00b question.
snmplabs.com site appears to be down. So some functions of mibdump.py will not work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.