Difference between revisions of "Python Bindings"

From Net-SNMP Wiki
Jump to: navigation, search
(Starting up example usage)
 
Line 4: Line 4:
  
  
In [1]: import netsnmp
+
{In [1]: import netsnmp
  
 
In [2]: var = netsnmp.Varbind('sysDescr.0')
 
In [2]: var = netsnmp.Varbind('sysDescr.0')
Line 14: Line 14:
  
 
In [4]: print res
 
In [4]: print res
('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',)}

Revision as of 14:00, 9 May 2007

Example Usage Ipython is the best way to get your feet wet with new libraries in python. Assuming 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',)}