Re: [Pysnmp-dev] SNMP set example
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2004-03-17 09:38:35
|
The SET operation is very similar to the GET one. That's why I've not included an example on SET into the distribution. But since this seems to be a confusing point, I'm going to add a SET example into the distro. Meanwhile, I've put it up on the web: http://pysnmp.sourceforge.net/examples/3.4.x/manager/setgen.html Please, let me know if anything still remains unclear. -ilya On Tue, 16 Mar 2004, Gregory Gee wrote: > 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'))] > >>> > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Pysnmp-dev mailing list > Pys...@li... > https://lists.sourceforge.net/lists/listinfo/pysnmp-dev > |