【发布时间】:2015-02-09 22:13:54
【问题描述】:
我正在尝试查找 Python 的 netsnmp 绑定是否可以使用 twisted 进行异步?如果有人有一个例子,那会很有帮助。我的目标是看看我是否可以以异步方式使用 Python 的 netsnmp 绑定来监听陷阱、发送 SNMP 获取请求等。
【问题讨论】:
标签: python network-programming twisted snmp
我正在尝试查找 Python 的 netsnmp 绑定是否可以使用 twisted 进行异步?如果有人有一个例子,那会很有帮助。我的目标是看看我是否可以以异步方式使用 Python 的 netsnmp 绑定来监听陷阱、发送 SNMP 获取请求等。
【问题讨论】:
标签: python network-programming twisted snmp
到目前为止,我发现 zenoss 写的 pynetsnmp 已经过时了。不确定是否有任何更新的库或者twisted 是否带有他们自己的 SNMP 库?
【讨论】:
你检查 pysnmp 了吗?库支持扭曲。 http://pysnmp.sourceforge.net/examples/v3arch/twisted/contents.html
from twisted.internet import reactor
from pysnmp.entity import engine, config
from pysnmp.entity.rfc3413 import cmdrsp, context
from pysnmp.carrier.twisted.dgram import udp
snmpEngine = engine.SnmpEngine()
config.addTransport(
snmpEngine,
udp.domainName,
udp.UdpTwistedTransport().openServerMode(('127.0.0.1', 161))
)
config.addV1System(snmpEngine, 'my-read-area', 'public')
config.addV1System(snmpEngine, 'my-write-area', 'private')
config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1))
config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
snmpContext = context.SnmpContext(snmpEngine)
cmdrsp.GetCommandResponder(snmpEngine, snmpContext)
cmdrsp.SetCommandResponder(snmpEngine, snmpContext)
cmdrsp.NextCommandResponder(snmpEngine, snmpContext)
reactor.run()
【讨论】:
http://twistedsnmp.sourceforge.net 就是这样的实现。
【讨论】: