[Pysnmp-dev] SNMP set example
Brought to you by:
elie
From: Gregory G. <gr...@sy...> - 2004-03-16 22:40:22
|
There seems to be lots of examples, but I was wondering if someone has an example of doing an SNMPSET using 3.4.2? I just downloaded pySNMP for the first time and followed the example in the README with no problems. A small example of setting 1 or 2 variables with a synchronous send and receive. Thanks, Greg [root@snoopy root]# python Python 2.2.2 (#1, Feb 24 2003, 19:13:11) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from pysnmp.proto import v1 >>> from pysnmp.proto.api import generic >>> from pysnmp.mapping.udp import role >>> req = v1.GetRequest() >>> req.apiGenGetPdu().apiGenSetVarBind([('1.3.6.1.2.1.1.1.0', v1.Null())]) >>> tr = role.manager(('192.168.10.1',161)) >>> (answer, src) = tr.send_and_receive(req.encode()) >>> rsp = v1.GetResponse() >>> rsp.decode(answer) '' >>> vars = rsp.apiGenGetPdu().apiGenGetVarBind() >>> print vars [('.1.3.6.1.2.1.1.1.0', OctetString('Instant Internet version 7.20'))] >>> |