Difference between revisions of "Python Bindings"

From Net-SNMP Wiki
Jump to: navigation, search
(Added link to the net-snmp/python/README)
 
(5 intermediate revisions by 4 users not shown)
Line 5: Line 5:
 
'''Example Usage:'''
 
'''Example Usage:'''
  
[http://ipython.scipy.org/moin/ ipython] is the best way to get your feet wet while  
+
[http://ipython.scipy.org/moin/ ipython] is the best way to get your feet wet while using the python bindings for Net-SNMP.
Assuming you got Net-SNMP to compile correctly and the egg to work:
+
This assumes you got Net-SNMP to compile correctly and the egg to work:
  
  
Line 23: Line 23:
 
('Linux machine.pretendco.com 2.4.7-10lpc #1 Tue Nov 13 03:44:18 EST 2001 i686',)
 
('Linux machine.pretendco.com 2.4.7-10lpc #1 Tue Nov 13 03:44:18 EST 2001 i686',)
 
</blockquote>
 
</blockquote>
 +
 +
'''Articles:'''
 +
* [https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp/python/README Python Bindings README]
 +
* Using Net-SNMP and IPython:  http://www.ibm.com/developerworks/aix/library/au-netsnmpnipython/
 +
 +
'''3rd Party Asynchronous Library'''
 +
 +
Because the Python bindings to Net-SNMP are synchronous, it effectively makes large parts of SNMP unusable in Python.
 +
One way around this is to use a 3rd party library that wraps up Net-SNMP in a Process Pool.  A library that does just that is called
 +
multicore-snmp and can be found here:
 +
 +
http://code.google.com/p/multicore-snmp/

Latest revision as of 09:42, 3 June 2009

Intro

Net-SNMP 5.4 and later contains Python bindings in the "python" sub-directory. They are not built by default. See python/README for further details.

Example Usage:

ipython is the best way to get your feet wet while using the python bindings for Net-SNMP. This assumes you got Net-SNMP to compile correctly and the egg to work:


In [1]: import netsnmp
In [2]: var = netsnmp.Varbind('sysDescr.0')
In [3]: res = netsnmp.snmpget(var, ...: Version = 1, ...: DestHost = 'localhost', ...: Community='public')
In [4]: print res ('Linux machine.pretendco.com 2.4.7-10lpc #1 Tue Nov 13 03:44:18 EST 2001 i686',)

Articles:

3rd Party Asynchronous Library

Because the Python bindings to Net-SNMP are synchronous, it effectively makes large parts of SNMP unusable in Python. One way around this is to use a 3rd party library that wraps up Net-SNMP in a Process Pool. A library that does just that is called multicore-snmp and can be found here:

http://code.google.com/p/multicore-snmp/