我根据文档尝试了各种方法,但我无法弄清楚如何在动态表中设置 MIB。我有设置标量值并且工作正常的代码。我知道我必须createAndGo(4)
在 RowStatus 上设置一个值,然后将其设置为active(1)
. 这是我尝试过的和 MIB 定义:
abcTable = MibTable((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4))
abcEntry = MibTableRow((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4, 1)).setIndexNames((0, "abc-mib", "abcEntryNum"))
abcRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4, 1, 1), RowStatus()).setMaxAccess("readcreate")
abcEntryNum = MibTableColumn((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4, 1, 2), Integer32().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 10))).setMaxAccess("noaccess")
abcName = MibTableColumn((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4, 1, 3), DisplayString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, 30))).setMaxAccess("readcreate")
abcType = MibTableColumn((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4, 1, 4), Integer().subtype(subtypeSpec=constraint.SingleValueConstraint(0,2,3,1,)).subtype(namedValues=namedval.NamedValues(("aa", 0), ("ab", 1), ("cb", 2), ("ca", 3), )).clone(0)).setMaxAccess("readcreate")
abcLocation = MibTableColumn((1, 3, 6, 1, 4, 1, 6367, 3, 21, 4, 1, 5), Integer32().subtype(subtypeSpec=constraint.ValueRangeConstraint(-1800, 1800))).setMaxAccess("readcreate")
def getvar(self, symbol):
"""Used to get the dot notation string from the symbol in the MIB"""
varObj, = self.mibBuilder.importSymbols('abc-mib', symbol)
return varObj.getName()
# Create the first Row
errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().setCmd( \
self.authData,
cmdgen.UdpTransportTarget((host_addr, 161)),
(getvar('abcRowStatus') + (1,), 4) )
我收到以下错误:
消息文件名行位置回溯
set_single abc.py
setCmd build\bdist.win32\egg\pysnmp\entity\rfc3413\oneliner\cmdgen.py 374
setCmd build\bdist.win32\egg\pysnmp\entity\rfc3413\oneliner\cmdgen. py 240
AttributeError:MibIdentifier 实例没有属性“getSyntax”
有任何想法吗?