Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

SNMP set request

by MikeW (Initiate)
on Jan 30, 2012 at 10:12 UTC ( #950733=perlquestion: print w/ replies, xml ) Need Help??
MikeW has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to set two OID's in the same PDU (so both OIDs and values are sent in the same packet) at present I am only able to send one at a time which does not trigger the hardware response as the two specific OID's with int values need to be set simultaneously in order to work.

I'm using perl along with SNMP_session and SNMP_util modules and the equipment supports both SNMPv1 and v2.

Has anyone got any ideas on how to achieve this?

Replies are listed 'Best First'.
Re: SNMP set request
by VinsWorldcom (Vicar) on Jan 30, 2012 at 20:59 UTC

    Use Net::SNMP:

    #! /usr/bin/perl use strict; use warnings; use Net::SNMP qw(:ALL); my ($session, $error) = Net::SNMP->session( -hostname => '', -version => 1, -community => 'public', ); my $result = $session->set_request( -varbindlist => [ '', INTEGER, 1, '', INTEGER, 2 ] ); $session->close();

    And the 'tcpdump' capture verifies both OID integers set in the same packet.

    tcpdump: listening on \Device\NPF_{731EA781-5FB3-4C71-944A-D70C7EE18AA +7} 15:54:50.646616 c4:17:fe:12:7d:75 > 58:6d:8f:78:ad:40, ethertype IPv4 +(0x0800), length 105: (tos 0x0, ttl 128, id 2841, offset 0, flags [none], proto: + UDP (17), length: 91) > [udp sum ok] { SN +MPv1 { Set Request(48) R=1833500672 . . +1.2=2 } } 0x0000: 586d 8f78 ad40 c417 fe12 7d75 0800 4500 Xm.x.@....}u..E. 0x0010: 005b 0b19 0000 8011 5062 c0a8 0a64 0a0a .[......Pb...d.. 0x0020: 0a01 cbd8 00a1 0047 4b23 303d 0201 0004 .......GK#0=.... 0x0030: 0670 7562 6c69 63a3 3002 046d 4900 0002 .public.0..mI... 0x0040: 0100 0201 0030 2230 0f06 0a2b 0601 0401 .....0"0...+.... 0x0050: 8386 5001 0102 0101 300f 060a 2b06 0104 ..P.....0...+... 0x0060: 0183 8650 0102 0201 02 ...P.....

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://950733]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2016-07-26 10:04 GMT
Find Nodes?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?

    Results (234 votes). Check out past polls.