【问题标题】:NoSuchObjectError pysnmpNoSuchObjectError pysnmp
【发布时间】:2015-09-11 03:41:38
【问题描述】:

当我将我的 pysnmp 操作传递给 oid 时,我目前遇到了一个错误。我得到的错误是

******************************NoSuchObjectError({'str': "无法解析节点名 ::(u'1', u'3', u'6', u'1', u'4', u'1', u'9', u'9', u'91', u'1', u'2', u'1', u'1', u'4') at "})***********

这是我的代码:

def SNMPWalkChildren(ipAddress, communityString, parentOID):
result = ""
try:
    DebugCode(ipAddress + " " + communityString + " " + parentOID)
    cmdGen = cmdgen.CommandGenerator()

    errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
        cmdgen.CommunityData(communityString),
        cmdgen.UdpTransportTarget((ipAddress, 161)),
        parentOID
    )

    if errorIndication:
        DebugCode(errorIndication)
    else:
        if errorStatus:
            DebugCode('%s at %s' % (
                errorStatus.prettyPrint(),
                errorIndex and varBindTable[-1][int(errorIndex)-1] or '?'
                )
            )
        else:
            for varBindTableRow in varBindTable:
                for name, val in varBindTableRow:                       
                    result += "\"" + str(name.prettyPrint()) + "\"" + ', \n'
                    DebugCode(name.prettyPrint())
    DebugCode(result[:-2])
    return result[:-2]
except Exception as e:
    DebugCode(str(e))

【问题讨论】:

  • 请问您的调用和堆栈跟踪是什么样的?

标签: python python-2.7 pysnmp


【解决方案1】:

确保 parentOID 是(ascii 或 utf-8)字符串:

'1.3.6.1.4.1.9.9.91.1.2.1.1.4'

或整数元组:

(1, 3, 6, 1, 4, 1, 9, 9, 91, 1, 2, 1, 1, 4)

但不是 unicode 字符串(u'1.3.6.1.4.1.9.9.91.1.2.1.1.4')。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多