0
我有一个自定义的MIB文件syzf-alarms.mib
。当我使用mibdump.py
生成与mibdump.py ~/syzf-ALARMS
pysnmp支持Python模块,我得到:PYSNMP 4.3.2 mibdump.py输出问题
Source MIB repo
sitories: file:///home/sbhattac, file:///usr/share/snmp/mibs, http://mibs.snmplabs.com/asn1/@[email protected]
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/notexts/@[email protected]
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: /home/sbhattac/.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: syzf-ALARMS
Destination format: pysnmp
Parser grammar cache directory: not used
Also compile all relevant MIBs: yes
Rebuild MIBs regardless of age: no
Do not create/update MIBs: no
Byte-compile Python modules: yes (optimization level 0)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Try various filenames while searching for MIB module: yes
Created/updated MIBs: syzf-ALARMS
Pre-compiled MIBs borrowed:
Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
Missing source MIBs:
Ignored MIBs:
Failed MIBs:
现在,它产生于home/sbhattac/.pysnmp/mibs
一个syzf-alarms.py/pyc
文件。
现在,我想在我的代码使用此模块:
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(cmdgen.CommunityData('public'),cmdgen.UdpTransportTarget(('localhost', 161)), cmdgen.ObjectIdentity('1, 3, 6, 1, 4, 1, 211, 1, 24, 11, 2, 1, 1, 7, 1, 3, 3, 1').addMibSource('/home/sbhattac/.pysnmp/mibs', 'syzf-ALARMS'))
我得到这样的错误:
File "/usr/local/lib/python2.7/site-packages/pysnmp/smi/builder.py", line 130, in _init
p = __import__(self._srcName, globals(), locals(), ['__init__'])
File "syzf-ALARMS.py", line 8, in <module>
(Integer, ObjectIdentifier, OctetString,) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
NameError: name 'mibBuilder' is not defined
这可能是什么原因?上述步骤可以吗?
感谢您的回复。你可以让我知道哪一个是可取的使用mibvariable或ObjectType(ObjectIdentity())? – sbhatta
建议使用ObjectType(ObjectIdentity)。 MibVariable方法已过时,仅支持向后兼容。 –