Net::SNMP dies on any OID error and doesn't return other possibly good values

Discussion in 'Perl' started by dan byers, Mar 5, 2004.

  1. dan byers

    dan byers Guest

    hey everyone, i'm working on a system to monitor devices through SNMP.

    i'm using the Net::SNMP modules by D.Town.

    i try to load the snmp session request with a set of OIDs to make the system
    run through the large set of queries faster.

    the problem i'm seeing is that if the request method does the request, and
    one particular index doesn't exist on the device, the entire request bails
    and no results are returned, thus skipping over any good OID's.

    has anyone gotten around this issue? is there a way for this module to
    properly parse out and handle errors?

    any insight would be very much appreciated! thanks

    if possible, please respond with a CC to 'dan at magma dot ca'.

    ========================================================

    #!/usr/bin/perl -w

    use strict;
    use Net::SNMP;

    $\ = "\n";

    print "[getting the session]";

    my ($session, $error) = Net::SNMP->session(
    -hostname => 'dev.domain.com',
    -version => 1,
    -nonblocking => 0,
    -timeout => 5,
    -retries => 5,
    -community => 'community string') ||
    print "ERROR: $! ";

    print "[session created]";

    my $result = $session->get_request(
    -varbindlist => [
    '.1.3.6.1.2.1.2.2.1.10.1',
    '.1.3.6.1.2.1.2.2.1.10.2',
    '.1.3.6.1.2.1.2.2.1.10.54344'
    ]
    ) || print "ERROR: $! " . $session->error();


    print "RESULT: [$result]";

    my $list = $session->var_bind_list();

    foreach my $key (keys %$list) {
    print "$key: " . $list->{$key};
    }

    print $list;

    foreach my $key (keys %$result) {
    print "$key => $result->{$key}";
    }


    1;
     
    dan byers, Mar 5, 2004
    #1
    1. Advertising

  2. On Fri, 5 Mar 2004 15:01:59 -0500, dan byers wrote:
    >
    > hey everyone, i'm working on a system to monitor devices through SNMP.
    >
    > i'm using the Net::SNMP modules by D.Town.
    >

    Consider using the perl module SNMP from netsnmp (ucd-snmp)
    (Less CPU usage)
    (there wil not be to change in the example below to convert)

    > i try to load the snmp session request with a set of OIDs to make the system
    > run through the large set of queries faster.


    If possible use snmp version 2 and bulk to get as few roundtrip delays as possible

    >
    > the problem i'm seeing is that if the request method does the request, and
    > one particular index doesn't exist on the device, the entire request bails
    > and no results are returned, thus skipping over any good OID's.
    >
    > has anyone gotten around this issue? is there a way for this module to
    > properly parse out and handle errors?


    With the SNMP module make a named varbindlist and look into that structure
    after call.
    >
    > if possible, please respond with a CC to 'dan at magma dot ca'.


    NO this is usenet. :)

    ***Example deleted***
    /hjj
     
    Hans =?iso-8859-1?Q?J=F8rgen?= Jakobsen, Mar 6, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    408
    Richard Bos
    Jan 17, 2007
  2. Toby Rodwell
    Replies:
    1
    Views:
    143
    Toby Rodwell
    Jan 7, 2007
  3. jc

    SNMP oid error

    jc, Jun 25, 2007, in forum: Ruby
    Replies:
    1
    Views:
    157
  4. Christopher M. Lusardi
    Replies:
    3
    Views:
    203
    Alan J. Flavell
    Oct 19, 2003
  5. milaus

    SNMP module to query net-snmp

    milaus, Aug 31, 2006, in forum: Perl Misc
    Replies:
    3
    Views:
    441
    Dr.Ruud
    Aug 31, 2006
Loading...

Share This Page