[Twisted-Python] SNMP support

Hi again, I needed SNMP (client) support for something I'm writing, and managed to hack my way to something that seems to work this aftenoon, based loosely on the DNS Boss system that was in 1.0.0. It uses the pure-python pysnmp (http://pysnmp.sourceforge.net/) for message encoding/decoding. I don't know whether this is the best way to organise this sort of thing, but it seemed to be about the only way to handle UDP effectively. I have no idea if I should be relying on transport.getHost() to return the same value at send time and receive time, and different from every other queries. There doesn't seem to be a way to request an ID for the SNMP request, but that may just be me not knowing how things work. Anyway, I'd like to know how people would like this reworked, especially if they can tell me how to think about it in a more twisted and/or pythonic way. Neil -- Neil Blakey-Milner nbm@mithrandr.moria.org

On Mon, 23 Dec 2002 17:26:58 +0200 Neil Blakey-Milner <nbm@mithrandr.moria.org> wrote:
Never ever ever use udp or tcp modules directly. Always use reactor APIs, e.e reactor.listenUDP and so on - they are documented in twiusted.internet.interfaces. -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python, Twisted, Zope and Java consulting ***> http://VoteNoWar.org -- vote/donate/volunteer <***

On Mon 2002-12-23 (17:26), Neil Blakey-Milner wrote:
Thanks to Itamar and Moshez for comments. Updated to 1.0.1 udp (much nicer), and added multiple oid queries. I don't like the way things fail when they do. If the host does not exist in DNS, I get: exceptions.AttributeError: 'NoneType' object has no attribute 'getHost' because the transport doesn't exist if the DNS fails. If the server is not running SNMP, I get: socket.error: (61, 'Connection refused') from udp.Port.doRead(), since it excepts to calling log.deferr. My requests do subsequently timeout, though, but I can't remove them from my queries list. Am I doing anything wrong? I just copied the general idea from the DNS code again. I also wonder whether I should be setting a timeout within the "boss", even a configurable one. Would it be better to leave it to the user as to whether to wait, or assume a default if they don't pass a timeout to the query and/or "boss"? Thanks again, Neil -- Neil Blakey-Milner nbm@mithrandr.moria.org

On Mon, 23 Dec 2002 17:26:58 +0200 Neil Blakey-Milner <nbm@mithrandr.moria.org> wrote:
Never ever ever use udp or tcp modules directly. Always use reactor APIs, e.e reactor.listenUDP and so on - they are documented in twiusted.internet.interfaces. -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python, Twisted, Zope and Java consulting ***> http://VoteNoWar.org -- vote/donate/volunteer <***

On Mon 2002-12-23 (17:26), Neil Blakey-Milner wrote:
Thanks to Itamar and Moshez for comments. Updated to 1.0.1 udp (much nicer), and added multiple oid queries. I don't like the way things fail when they do. If the host does not exist in DNS, I get: exceptions.AttributeError: 'NoneType' object has no attribute 'getHost' because the transport doesn't exist if the DNS fails. If the server is not running SNMP, I get: socket.error: (61, 'Connection refused') from udp.Port.doRead(), since it excepts to calling log.deferr. My requests do subsequently timeout, though, but I can't remove them from my queries list. Am I doing anything wrong? I just copied the general idea from the DNS code again. I also wonder whether I should be setting a timeout within the "boss", even a configurable one. Would it be better to leave it to the user as to whether to wait, or assume a default if they don't pass a timeout to the query and/or "boss"? Thanks again, Neil -- Neil Blakey-Milner nbm@mithrandr.moria.org
participants (2)
-
Itamar Shtull-Trauring
-
Neil Blakey-Milner