Skip to content

Commit

Permalink
Added cookbook entry for bulk tables.
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
exhuma committed Oct 24, 2016
1 parent 2f911af commit 77fc902
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,43 @@ Output
1.3.6.1.2.1.6.15.0 b'\x00'
1.3.6.1.2.1.6.20.1.4.1.4.0.0.0.0.199 b'\x01'
Retrieve Table With Bulk Requests
---------------------------------

See:

* :py:func:`puresnmp.x690.util.tablify`
* :py:func:`puresnmp.bulkwalk`

:py:func:`puresnmp.table` is a convenience wrapper around
:py:func:`puresnmp.walk` and :py:func:`puresnmp.x690.util.tablify`.
:py:func:`~puresnmp.x690.util.tablify` can be used on any walk result, and, by
that definition also over a bulkwalk result!

To turn a bulkwalk result into a table use the following as an example:

.. code-block:: python
from pprint import pprint
from puresnmp import bulkwalk
from puresnmp.x690.util import tablify
ip = '127.0.0.1'
community = 'private'
oids = [
'1.3.6.1.2.1.2.2.1.2', # name
'1.3.6.1.2.1.2.2.1.6', # MAC
'1.3.6.1.2.1.2.2.1.22', # ?
]
result = bulkwalk(ip, community, oids)
table = tablify(result)
pprint(table)
Output
~~~~~~

.. code-block:: python
[{'0': '10', '2': b'eth0', '22': '0.0', '6': b'\x02B\xac\x11\x00\x02'},
{'0': '1', '2': b'lo', '22': '0.0', '6': b''}]

0 comments on commit 77fc902

Please sign in to comment.