我使用的问题描述的方法使用pysnmp翻译从MIB文本的约定OID值对根据MIB文本惯例翻译OID和OID值。
使用测试OID和测试OID珍惜我的代码如下:
from pysnmp.smi import builder, view
from pysnmp.entity.rfc3413.oneliner import mibvar
from pysnmp.proto import rfc1902
from pyasn1.type import univ
mibBuilder = builder.MibBuilder()
mibPath = mibBuilder.getMibSources() + (builder.DirMibSource('/home/rong/NOP_Dev/test'),)
mibBuilder.setMibSources(*mibPath)
mibBuilder.loadModules('NORTEL-ALARM-EXT-MIB')
mibViewController = view.MibViewController(mibBuilder)
varName = mibvar.MibVariable(univ.ObjectIdentifier('1.3.6.1.4.1.562.29.6.1.1.1.1')).resolveWithMib(mibViewController)
print(varName.getMibNode().getSyntax().clone(1).prettyPrint())
当我运行我的代码,我得到了如下错误:
Traceback (most recent call last):
File "./pysnmp_test.py", line 82, in <module>
varName = mibvar.MibVariable(univ.ObjectIdentifier('1.3.6.1.4.1.562.29.6.1.1.1.1')).resolveWithMib(mibViewController)
File "/home/rong/NOP_Dev/lib/python3.4/site-packages/pysnmp/entity/rfc3413/oneliner/mibvar.py", line 169, in resolveWithMib
self.__indices = rowNode.getIndicesFromInstId(suffix)
File "<string>", line 1076, in getIndicesFromInstId
File "<string>", line 899, in setFromName
pysnmp.smi.error.SmiError: Short OID for index NnExtAlarmEventType()
该文本,约定如下:
NnExtAlarmEventType ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Nortel version of IANA Event Type"
SYNTAX INTEGER
{
other (1),
communicationsAlarm (2),
qualityOfServiceAlarm (3),
processingErrorAlarm (4),
equipmentAlarm (5),
environmentalAlarm (6),
integrityViolation (7),
operationalViolation (8),
physicalViolation (9),
securityServiceOrMechanismViolation (10),
timeDomainViolation (11)
}
帮助这个错误,将不胜感激!