我从以下位置下载示例
:http://snmplabs.com/pysnmp/examples/v3arch/twisted/agent/cmdrsp/agent-side-mib-implementations.html
并尝试运行:
snmpwalk -v2c -c public 127.0.0.1 .1.3.6
获取:
Unhandled Error
Traceback (most recent call last):
File "implementing-scalar-mib-objects1.py", line 81, in <module>
reactor.run()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1261, in run
self.mainLoop()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1270, in mainLoop
self.runUntilCurrent()
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 896, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/usr/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 70, in _cbFun
self, transportDomain, transportAddress, incomingMessage
File "/usr/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun
self, transportDomain, transportAddress, wholeMsg
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 433, in receiveMessage
PDU, maxSizeResponseScopedPDU, stateReference)
File "/usr/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 150, in processPdu
self.handleMgmtOperation(snmpEngine, stateReference, contextName, PDU)
File "/usr/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 293, in handleMgmtOperation
rspVarBinds = mgmtFun(*varBinds, **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/instrum.py", line 261, in readNextVars
return self.flipFlopFsm(self.fsmReadNextVar, *varBinds, **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/instrum.py", line 227, in flipFlopFsm
rval = mgmtFun((tuple(name), val), **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py", line 527, in readGetNext
return node.readGetNext((nextName, val), **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py", line 660, in readGetNext
return MibTree.readGetNext(self, varBind, **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py", line 527, in readGetNext
return node.readGetNext((nextName, val), **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py", line 780, in readGetNext
return self.readGet(varBind, **context)
File "/usr/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py", line 761, in readGet
return self.name, self.getValue(name, **context)
exceptions.TypeError: getValue() got an unexpected keyword argument 'cbCtx'
在v1中,我得到的答案是空的:
$ snmpwalk -v 1 -c public 127.0.0.1 1.3.6
End of MIB
在Debian测试中为python3-pysnmp4 4.4.6-1。
答案 0 :(得分:0)
当您引用python3-pysnmp-4.4.6时,您的回溯来自Python 2.7。请确保您使用的pysnmp版本与示例兼容。
请注意,除非添加以下内容,否则您正在运行的example script不会响应SNMP v1查询:
config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (1, 3, 6, 5))
打电话给它。