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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dan byers

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


    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;



  • Hans Jørgen Jakobsen

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

    On Fri, 5 Mar 2004 15:01:59 -0500, dan byers wrote:[color=blue]
    >
    > hey everyone, i'm working on a system to monitor devices through SNMP.
    >
    > i'm using the Net::SNMP modules by D.Town.
    >[/color]
    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)
    [color=blue]
    > 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.[/color]

    If possible use snmp version 2 and bulk to get as few roundtrip delays as possible
    [color=blue]
    >
    > 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?[/color]

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

    NO this is usenet. :-)

    ***Example deleted***
    /hjj

    Comment

    Working...