trehn / hnmp

High-level Python SNMP library
ISC License
49 stars 16 forks source link

Added SNMP.rows() method. #8

Closed mjuenema closed 9 years ago

mjuenema commented 9 years ago

The SNMP.rows() method is a wrapper for the SNMP.table() method which re-arranges and returns the SNMP.table.columns as a list of rows. Each row contains a tuple of columns. SNMP.rows() takes the same arguments as SNMP.table().

>>> ifEntry = '     1.3.6.1.2.1.2.2.1'
>>> snmp.rows(ifEntry)
[(1, u'GigabitEthernet0', 6, 1500, 100000000, '\x0ch\x03&\x80\xef', 2, 2, datetime.timedelta(43, 85641, 860000), 0, 0, 0, 0, 0, 60, 0, 0, 0), 
 (2, u'FastEthernet0', 6, 1500, 100000000, '\x0ch\x03&\x80\xd8', 1, 1, datetime.timedelta(0, 111, 580000), 3006733001L, 32932557, 0, 0, 0, 2156739797L, 21664124, 0, 0),
  ...]

SNMP.rows() may not be the best name for the method. Maybe someone can come up with a better name.

trehn commented 9 years ago

Why do you need this in addition to table.rows? I have just made row content OrderedDicts (8ca9ef663), so you should basically get the same thing using [row.values() for row in table.rows].

mjuenema commented 9 years ago

That's a valid point. Sorry I missed the table.rows property. You can reject that pull request then. Viele Gruesse, Markus