Re: [pysnmp-users] Bug in 3.3.4 snmpwalk.py?
Brought to you by:
elie
From: Mike C. F. <mcf...@ro...> - 2003-08-13 15:18:17
|
A list for users of pure-Python SNMP framework <pysnmp-users.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/pysnmp-users>, <mailto:pys...@li...?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum=pysnmp-users> Ilya Etingof wrote: >Yeah, that first GET request has been added to make snmpwalk.py behaving >closer to Net-SNMP's snmpwalk. This has been implemented to do GET >unconditionally and not to ignore [possible] errors so that's buggy. > >I've just re-worked the snmpwalk*.py code to fire GET only when >instructed from command line (-Ci) e.g. in the same way as it's done in >Net-SNMP. Please, try it out (CVS rev 1.3.2.19) and let me know in case of >any probs: > > Seems to fix that problem. You'll want to use a slightly more involved check for "is it an increasing OID value": 11:03:08 mcfletch@cmon:~/pysnmp-3.3.4/examples $ python snmpwalk.py 172.16.0.1 public .1.3.6.1.2.1.10.127.1.3.3.1.3 .1.3.6.1.2.1.10.127.1.3.3.1.3.1 ---> '172.16.9.125' .1.3.6.1.2.1.10.127.1.3.3.1.3.2 ---> '172.16.6.38' .1.3.6.1.2.1.10.127.1.3.3.1.3.3 ---> '172.16.2.229' .1.3.6.1.2.1.10.127.1.3.3.1.3.4 ---> '172.16.4.12' .1.3.6.1.2.1.10.127.1.3.3.1.3.5 ---> '172.16.10.127' .1.3.6.1.2.1.10.127.1.3.3.1.3.6 ---> '172.16.12.175' .1.3.6.1.2.1.10.127.1.3.3.1.3.7 ---> '172.16.10.140' .1.3.6.1.2.1.10.127.1.3.3.1.3.8 ---> '172.16.118.245' .1.3.6.1.2.1.10.127.1.3.3.1.3.9 ---> '172.16.110.247' Error: OID not increasing: [('.1.3.6.1.2.1.10.127.1.3.3.1.3.9', '.1.3.6.1.2.1.10.127.1.3.3.1.3.10')] 11:03:19 mcfletch@cmon:~/pysnmp-3.3.4/examples $ i.e. str(10) < str(9) lexically. Line 164:173 in the source, I think this is approximately what you want (untested as of yet, as I'm not sure which restriction is actually intended): def cmpOID( x, y ): """just checks if we're past end of table""" x = x.split('.') y = y.split('.') return y[:len(x)-1] == x[:-1] or def cmpOID( x, y ): """converts to integers and does increasing-numbers check""" x = map(int, x.split('.')) y = map(int, y.split('.')) return y > x or (from my current code): if suffix: sentinel = oids[0].split('.') sentinel = sentinel[:-suffix] sentinel = ".".join(sentinel) else: sentinel = oids[0] ... if not testOID.startswith( sentinel ): break but that's a very different check for "end-of-table" which assumes that the first OID doesn't run out before everything else does, (and does no always-increasing-numbers check). Enjoy, Mike _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |