473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

SNMP Toolkit

Hi,

I'm looking for a high-performance SNMP manager toolkit (SNMPv1 / v2,
GET / GETNEXT / GETBULK) I can use with Python on Windows2K/XP. I
wonder if anyone has got any suggestions? Commercial software is
fine, as it's for a specialised in-house application.

I've tried PySNMP which, while a fine piece of code (I've learnt a lot
looking through it!), it's fairly CPU intensive in my application.
I've also tried using UCDSNMP via popen() but that has a tendency to
hang in a multi-threaded environment.

So, does anyone know of a solid, multi-threading capable, fast SNMP
library with a reasonable Python interface that will run on Windows
without me needing to get my head round a C compiler to build it? I
know I should be all manly-man and hew my own C-based SNMP library
from scratch but, basically, while I'm only a mediocre Python
programmer, the last compiled language I used was COBOL...

Thanks!
Matthew.
Jul 18 '05 #1
10 9985
>>>>> "Matthew" == Matthew Bell <li****@cix.co.uk> writes:

Matthew> Hi, I'm looking for a high-performance SNMP manager
Matthew> toolkit (SNMPv1 / v2, GET / GETNEXT / GETBULK) I can use
Matthew> with Python on Windows2K/XP. I wonder if anyone has got
Matthew> any suggestions? Commercial software is fine, as it's
Matthew> for a specialised in-house application.

Matthew> I've tried PySNMP which, while a fine piece of code (I've
Matthew> learnt a lot looking through it!), it's fairly CPU
Matthew> intensive in my application. I've also tried using
Matthew> UCDSNMP via popen() but that has a tendency to hang in a
Matthew> multi-threaded environment.

Matthew> So, does anyone know of a solid, multi-threading capable,
Matthew> fast SNMP library with a reasonable Python interface that
Matthew> will run on Windows without me needing to get my head
Matthew> round a C compiler to build it? I know I should be all
Matthew> manly-man and hew my own C-based SNMP library from
Matthew> scratch but, basically, while I'm only a mediocre Python
Matthew> programmer, the last compiled language I used was
Matthew> COBOL...

Matthew> Thanks! Matthew.

Pysnmp is the only 100% pure Python SNMP implementation I'm aware
of. Perhaps you could address your program's inefficiencies instead?
What are you doing that's so CPU intensive? SNMP agents/managers that
I've worked on (admittedly not using Python) were always I/O bound,
rather than CPU bound.

Jul 18 '05 #2
Les Smithson <ls******@NOhare.SPAM.demon.co.uk> wrote in message news:<m3************@hare.demon.co.uk>...
>> "Matthew" == Matthew Bell <li****@cix.co.uk> writes:

Matthew> Hi, I'm looking for a high-performance SNMP manager
Matthew> toolkit (SNMPv1 / v2, GET / GETNEXT / GETBULK) I can use
Matthew> with Python on Windows2K/XP.

[...deletia...]
Pysnmp is the only 100% pure Python SNMP implementation I'm aware
of. Perhaps you could address your program's inefficiencies instead?
What are you doing that's so CPU intensive? SNMP agents/managers that
I've worked on (admittedly not using Python) were always I/O bound,
rather than CPU bound.


The application is monitoring 30+ big LAN switches with a large
variety of information being collected from each one. Using UCD-SNMP
then (if we ignore the way it tends to hang sometimes), indeed, I/O is
the limiting factor rather than CPU. The Python code I've written
that deals with all the data amazes me by how relatively little CPU it
consumes (yay for Python!); if I could find a way to get UCD-SNMP to
work reliably in a multi-threaded environment then I'd happily carry
on using that. But the hanging is getting really frustrating as not
even select() seems to be able to catch it. It just hangs.

Using PySNMP rather than UCD-SNMP certainly gets round the random
hanging, but it does make CPU go through the roof.

I'm not actually necessarily looking for a pure Python SNMP toolkit.
To be honest, given the large amounts of SNMP traffic that this
application has to generate, it would make an awful lot of sense to
have the low-level SNMP grunt work done in a C / C++ library and then
have the Python code just deal with the processed OIDs and values.
It's just that I can't find any such library that'll run on Win32 and
that has a convenient Python wrapper. I've got a recollection that I
stumbled across a commercial C++ based SNMP library that came with a
Python wrapper about a year ago, but no amount of googling has found
it again :-(

I have found any number of native COM/.NET/ASP/etc C++ SNMP toolkits
and tried using the Python Win32 extensions to talk to them but I just
don't understand enough about low-level Win32 calls, event handling
etc to get them to work, particularly as the code examples typically
expect you to either be using Visual C++ or Visual Basic.

Thanks anyway,
Matthew.
Jul 18 '05 #3
>>>>> "Matthew" == Matthew Bell <li****@cix.co.uk> writes:

Matthew> I have found any number of native COM/.NET/ASP/etc C++
Matthew> SNMP toolkits and tried using the Python Win32 extensions
Matthew> to talk to them but I just don't understand enough about
Matthew> low-level Win32 calls, event handling etc to get them to
Matthew> work, particularly as the code examples typically expect
Matthew> you to either be using Visual C++ or Visual Basic.

Matthew> Thanks anyway, Matthew.

I have to ask this - did you look at snmpy
(http://snmpy.sourceforge.net)? This uses ucd-snmp/net-snmp for the
grunt. It doesn't claim to be ported to Windows, but net-snmp is, and
the C module in snmpy doesn't *look* that difficult to build on
Windows.

Jul 18 '05 #4
In article <m3************@hare.demon.co.uk>,
Les Smithson <ls******@NOhare.SPAM.demon.co.uk> wrote:
>> "Matthew" == Matthew Bell <li****@cix.co.uk> writes:


Matthew> I have found any number of native COM/.NET/ASP/etc C++
Matthew> SNMP toolkits and tried using the Python Win32 extensions
Matthew> to talk to them but I just don't understand enough about
Matthew> low-level Win32 calls, event handling etc to get them to
Matthew> work, particularly as the code examples typically expect
Matthew> you to either be using Visual C++ or Visual Basic.

Matthew> Thanks anyway, Matthew.

I have to ask this - did you look at snmpy
(http://snmpy.sourceforge.net)? This uses ucd-snmp/net-snmp for the
grunt. It doesn't claim to be ported to Windows, but net-snmp is, and
the C module in snmpy doesn't *look* that difficult to build on
Windows.


What have been people's experiences with snmpy? The last time I looked
at it (over a year ago), I had troubles building it (on linux) because
it had dependencies on an oldish version of net-snmp.

I do a lot of SNMP work, but have never really found a good python SNMP
package. I looked at PySNMP (the pure python one) but never managed to
get that to work either. It also just seems wrong to be doing all the
low-level BER and packet building stuff in Python.
Jul 18 '05 #5
Les Smithson wrote:
>>"Matthew" == Matthew Bell <li****@cix.co.uk> writes:
>>
>>
....
Matthew> I've tried PySNMP which, while a fine piece of code (I've
Matthew> learnt a lot looking through it!), it's fairly CPU
Matthew> intensive in my application. I've also tried using
Matthew> UCDSNMP via popen() but that has a tendency to hang in a
Matthew> multi-threaded environment.

....
SNMP agents/managers that
I've worked on (admittedly not using Python) were always I/O bound,
rather than CPU bound.

PySNMP is actually a *very* heavy library compared to C ASN.1 parsers.
I've certainly run into situations where it's just not fast enough to do
what we want to do. Thing is, it's flexible and can be readily
integrated with Twisted, so we still use it, even if it does mean it can
take 10 minutes to scan a plant. That's all processor-bound time, not
IO bound.

Some day I'm going to try to squeeze some money out of the budget to
spend a week on figuring out how to make PySNMP faster, but until then
I'm afraid I just don't have a good suggestion for large SNMP querying
tasks.

Have fun,
Mike

________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
blog: http://zope.vex.net/~mcfletch/plumbing/
Jul 18 '05 #6
Mike C. Fletcher wrote:

PySNMP is actually a *very* heavy library compared to C ASN.1 parsers.
I've certainly run into situations where it's just not fast enough to do
what we want to do.
[..]
That's all processor-bound time, not
IO bound.


AFAIK the BER encoding/decoding is implemented in pure Python. If one has
the time to implement these routines in C it'd be much less CPU intensive I
guess.

I wish support for BER and DER to be in the standard lib...

Ciao, Michael.
Jul 18 '05 #7
Have you tried yapsnmp: http://yapsnmp.sourceforge.net/ ?
It is a Python wrapper around net-snmp, so should be fast.
It also claims to be thread-safe.
The problem you could have is that it's advertised as a posix module
only. But the wrapper is built using SWIG, so it should be possible to
build it for Windows without too much hassle.
Note that I've never used it myself, so can't comment on the package
itself.
However, I will have to do some snmp coding soon, and it's the first
one I will try.
Jul 18 '05 #8
Michael Str?der <mi*****@stroeder.com> wrote:

[ skipped ]
AFAIK the BER encoding/decoding is implemented in pure Python. If one has
the time to implement these routines in C it'd be much less CPU intensive I
guess.


I've got an impression, that building/parsing BER is not computationally
intensive. In fact, BER encoding has been designed to cope with rather limited
resources (in terms of about 20 yo hardware!).

As an alternative bottleneck I'd rather propose 1) object instantiation and
2) function calls. As of this writing, pysnmp.asn1 code is designed as a top-down
parser what implies intensive recursion and object creation. Although not a real
receipt but rater a workaround, I'd suggest caching and reusing top-level
ASN.1/SNMP objects (such as SNMP message) inside your app whenever possible.
This might safe lots of CPU on a long run.

-ilya
Jul 18 '05 #9
Les Smithson <ls******@NOhare.SPAM.demon.co.uk> wrote in message news:<m3************@hare.demon.co.uk>...
I have to ask this - did you look at snmpy
(http://snmpy.sourceforge.net)? This uses ucd-snmp/net-snmp for the
grunt. It doesn't claim to be ported to Windows, but net-snmp is, and
the C module in snmpy doesn't *look* that difficult to build on
Windows.


Yes, I did look at snmpy. And was instantly scared off by the obvious
need to hack about with the C module to get it to compile on Win32. I
haven't even been able to get net-snmp itself to compile on Win32 - I
tried to follow the net-snmp readme about compiling it with cygwin and
just ended up in a world of pain. The thought of doing the same for
snmpy brings me out in hives.

For better or for worse, I don't come from a UNIX / C background and
so while such things may be straightforward for some, they're not for
me.

Thanks anyway,
Matthew.
Jul 18 '05 #10
>>>>> "Ilya" == Ilya Etingof <il**@cray.glas.net> writes:

Ilya> I've got an impression, that building/parsing BER is not
Ilya> computationally intensive. In fact, BER encoding has been
Ilya> designed to cope with rather limited resources (in terms of
Ilya> about 20 yo hardware!).

Ilya> As an alternative bottleneck I'd rather propose 1) object
Ilya> instantiation and 2) function calls. As of this writing,
Ilya> pysnmp.asn1 code is designed as a top-down parser what
Ilya> implies intensive recursion and object creation. Although
Ilya> not a real receipt but rater a workaround, I'd suggest
Ilya> caching and reusing top-level ASN.1/SNMP objects (such as
Ilya> SNMP message) inside your app whenever possible. This might
Ilya> safe lots of CPU on a long run.

Ilya> -ilya

Out of interest, I ran a simple pysnmp test using the Python
profiler. The test case was a 1000 loops of a GETREQUEST/GETRESPONSE
of sysDescr, using pysnmp 2.0.8 on a Linux box. The top 10, sorted by
time, were:
514003 function calls in 8.100 CPU seconds

Ordered by: internal time
List reduced from 63 to 10 due to restriction <10>

ncalls tottime percall cumtime percall filename:lineno(function)
18000 0.760 0.000 1.300 0.000 v1.py:240(update)
14000 0.560 0.000 2.140 0.000 asn1.py:284(decode)
3000 0.520 0.000 0.770 0.000 asn1.py:633(num2str)
13000 0.490 0.000 1.600 0.000 asn1.py:263(encode)
25000 0.370 0.000 0.510 0.000 asn1.py:206(__init__)
52000 0.350 0.000 0.350 0.000 asn1.py:245(update)
4000 0.330 0.000 1.340 0.000 asn1.py:750(decode)
2000 0.330 0.000 0.700 0.000 asn1.py:606(str2num)
30000 0.320 0.000 1.190 0.000 v1.py:210(__setitem__)
21000 0.270 0.000 0.270 0.000 asn1.py:142(decode_tag)
By fiddling with the args/ARGS dictionary merging code in
v1.py:240(update), I cut its internal time by around 50%. I haven't
found any significant optimisations elsewhere. I can't figure out
where the time goes in the asn1.py decode/encode/update functions -
they don't have any loops and there's not much to them.

Would using the array module for holding the PDU make a difference?


Jul 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dan byers | last post by:
hey everyone, i'm working on a system to monitor devices through SNMP. i'm using the Net::SNMP modules by D.Town. i try to load the snmp session request with a set of OIDs to make the system...
3
by: Kevin Ingram | last post by:
Is it possible to connect to devices and read SNMP data with ASP? I did a search and all I could find was utilities for sale to do it, wondered if it can be done using straight ASP. We are using...
1
by: ZacBowling | last post by:
Does anyone have an idea of how to access the SNMP API or WMI SNMP provider in C#/.NET? I need to query a Ascend MAX's SNMP service with a custom MIB in .NET. I won't be modify anything on the MAX...
0
by: Chris | last post by:
For the IBM DB2 Development following this group. SNMP is coming back in a big way. Changes in Version 2c and adoptions of Version 3 are ushering in the adoption of SNMP back into the enterprise....
10
by: Bennett F. Dill | last post by:
Hi I'd like help writing a c# console app that can send an SNMP trap. I've seen some documents on writng an SNMP server, but I don't want to receive traps, I only want to send them. Thanks Ben
0
by: ramgce2003 | last post by:
Dear all... We have an NMS Software(Created by using GUI(Window) based application in VC++) already used to comminicate to our SNMP Agent Note::: 1. Consider NMS Software(actas a client)...
1
by: idoha | last post by:
Hi, I am trying to determine the SNMP status on remote machine. I need to distinguish between two possible options, where the SNMP is not active: 1)When the SNMP listener is not active on a...
1
by: Dirk Van de moortel | last post by:
{ OOPS, posted this to moderated group perl.cpan.discuss as well, so it can take a while to get through, if it gets through at all Otherwise sorry for duplicate posting } We need to set up a...
7
by: moon1 | last post by:
how will I change the code the 1st code according to the 2nd one? 1st code sub snmpGet(@) { # Assign arguments my ($deviceName)=$_; # Device name to read from my...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.