首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NoSuchObjectError pysnmp

NoSuchObjectError pysnmp
EN

Stack Overflow用户
提问于 2015-09-10 14:38:14
回答 1查看 414关注 0票数 0

当前,当我将pysnmp操作传递给1D时,我得到了一个错误。我所犯的错误是

*************************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') (})*

这是我的密码:

代码语言:javascript
复制
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))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-10 19:41:38

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

代码语言:javascript
复制
'1.3.6.1.4.1.9.9.91.1.2.1.1.4'

或整数的元组:

代码语言:javascript
复制
(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')。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32504899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档