[Twisted-Python] SNMP in Twisted

I was given the task to have a program to send SNMP get requests and recieve SNMP traps. There is a PySNMP package out there, and I guess that it's a blocking call to get data from an SNMP server, especially when doing a walk style request. My questions are, 1. Should one attempt on doing the hair raising task of doing the SNMP client and Server protocols? (Hopefully, you should never need to write your own protocols) 2. Use the PySNMP library as is, no matter how blocking that can be? 3. Use PySNMP calls in a thread? 4. Use the command line executables of ucd-snmp (or net-snmp) and use the reactor.spawnProcess() calls. Get SNMP traps using syslog named pipes. All are valid answers, though I pretty much think that 1. is the best way to go, BUT, looking at SNMP rfcs, it could very well prove to be an almost impossible task (especially for a newbie like me:).

On Wed, May 28, 2003 at 03:48:55PM +0800, Wari Wahab wrote:
Have you seen http://twistedmatrix.com/pipermail/twisted-python/2002-December/002456.html ? (In general, the best approach to Twistifying a protocol in another Python library is to reuse the message decoding and encoding, but use Twisted to handle all the networking. This usually means writing a Protocol subclass that delegates most of the work in dataReceived to the library, but obivously this depends on the protocol...) -Andrew.

Andrew Bennetts wrote:
Have you seen http://twistedmatrix.com/pipermail/twisted-python/2002-December/002456.html
OMG! That answer one half of my question, thanks. Should of probe around first.
So do you mean that twisted is the one sending out bytes to and from the network, and pass dataReceived to the library? This depends if the library has the encode and decode routines right? If the library does it's own networking, then I cannot do it this way, am I right in saying that?

On 2003.05.28 05:41, Wari Wahab wrote:
Not really - the lib might do its own networking, but it'll often have, as moshez put it, semi-internal methods for doing decoding and encoding. You just need to bypass its network-using layer. -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://twistedmatrix.com/users/radix.twistd/

On Wed, 28 May 2003, Wari Wahab <wari@home.wari.org> wrote:
2. Use the PySNMP library as is, no matter how blocking that can be?
It's often possible to use a library *partially*, if it's structured correctly. E.g., have the network code in Twisted pass in data to some semi-internal PySNMP function. As an example, this is how the XML-RPC and SOAP support work -- they use the parsing code from xmlrpclib and SOAPpy, but use Twisted's network code. If this isn't possible, see if you can modify PySNMP a little to decouple the network code from the protocol parsing code, and send back the PySNMP guys the patch. Often, authors will take this kind of patches, especially if accompnied by "Twisted support" :). Just don't make it *depend* on Twisted. -- Moshe Zadka -- http://moshez.org/ Buffy: I don't like you hanging out with someone that... short. Riley: Yeah, a lot of young people nowadays are experimenting with shortness. Agile Programming Language -- http://www.python.org/

On Wed, May 28, 2003 at 03:48:55PM +0800, Wari Wahab wrote:
Have you seen http://twistedmatrix.com/pipermail/twisted-python/2002-December/002456.html ? (In general, the best approach to Twistifying a protocol in another Python library is to reuse the message decoding and encoding, but use Twisted to handle all the networking. This usually means writing a Protocol subclass that delegates most of the work in dataReceived to the library, but obivously this depends on the protocol...) -Andrew.

Andrew Bennetts wrote:
Have you seen http://twistedmatrix.com/pipermail/twisted-python/2002-December/002456.html
OMG! That answer one half of my question, thanks. Should of probe around first.
So do you mean that twisted is the one sending out bytes to and from the network, and pass dataReceived to the library? This depends if the library has the encode and decode routines right? If the library does it's own networking, then I cannot do it this way, am I right in saying that?

On 2003.05.28 05:41, Wari Wahab wrote:
Not really - the lib might do its own networking, but it'll often have, as moshez put it, semi-internal methods for doing decoding and encoding. You just need to bypass its network-using layer. -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://twistedmatrix.com/users/radix.twistd/

On Wed, 28 May 2003, Wari Wahab <wari@home.wari.org> wrote:
2. Use the PySNMP library as is, no matter how blocking that can be?
It's often possible to use a library *partially*, if it's structured correctly. E.g., have the network code in Twisted pass in data to some semi-internal PySNMP function. As an example, this is how the XML-RPC and SOAP support work -- they use the parsing code from xmlrpclib and SOAPpy, but use Twisted's network code. If this isn't possible, see if you can modify PySNMP a little to decouple the network code from the protocol parsing code, and send back the PySNMP guys the patch. Often, authors will take this kind of patches, especially if accompnied by "Twisted support" :). Just don't make it *depend* on Twisted. -- Moshe Zadka -- http://moshez.org/ Buffy: I don't like you hanging out with someone that... short. Riley: Yeah, a lot of young people nowadays are experimenting with shortness. Agile Programming Language -- http://www.python.org/
participants (4)
-
Andrew Bennetts
-
Christopher Armstrong
-
Moshe Zadka
-
Wari Wahab