Fellow monks,

I strongly suspect that the answer to this may be a non-Perl one, but here goes anyway.

I am using Net::SNMP to retrieve configuration data from some remote devices. Some of the data that I am after is in the form of IP ranges, ie. a "starting IP" and an "ending IP".

To pull this data, I've written a small routine which I call each time I need to (once the net::snmp session is established). The routine is as follows:

sub get_ip_list { my $table_index = shift; my $oid = "$base_oid"."$oids{$version}".".$table_index"; my $table = $session->get_table( -baseoid => $oid, ); if (!defined $table) { my $err = $session->error; print "ERROR: $err\n"; return 0; } my $ips; for my $entry (sort keys %{$table}) { my $tail; ($tail = $entry) =~ s/^$oid//; if ($tail =~ m/^\.5\.1\.4\.(\d)/) { $ips->{$1}{start} = $table->{$entry}; } elsif ($tail =~ m/^\.5\.1\.6\.(\d)/) { $ips->{$1}{end} = $table->{$entry}; } } return $ips; }

The above is called as get_ip_list(n), where n represents the SNMP table index to use as a starting point. Mostly, it works fine. However, with certain table indexes the get_table() method returns undef, indicating an error. The error I get is:

ERROR: Received noError(0) error-status at error-index 1

Apart from the fact that I'm not really sure what that error means, I'm also a bit bewildered as to why it's failing in the first place. This is because if I do a manual snmpwalk (via command line) using the same starting OID - I get the expected result. An (edited) example looks something like this:

darren@monitor:~/nomadix> snmpwalk -v1 -c XXXXX B x.x.x.x 1.3.6.1.4.1. +3309.1.4.17 SNMPv2-SMI::enterprises.3309.1.4.17.1.0 = INTEGER: 1 SNMPv2-SMI::enterprises.3309.1.4.17.2.0 = INTEGER: 1 SNMPv2-SMI::enterprises.3309.1.4.17.3.0 = INTEGER: 1 SNMPv2-SMI::enterprises.3309.1.4.17.4.0 = INTEGER: 0 SNMPv2-SMI::enterprises.3309.1.4.17.5.1.2.1 = Counter32: 1 SNMPv2-SMI::enterprises.3309.1.4.17.5.1.4.1 = IpAddress: 61.115.200.69 SNMPv2-SMI::enterprises.3309.1.4.17.5.1.6.1 = IpAddress: 61.115.200.99 SNMPv2-SMI::enterprises.3309.1.4.17.5.1.10.1 = INTEGER: 1

However, when I use the above OID (1.3.6.1.4.1.3309.1.4.17) in my code with get_table() - it fails. I do suspect that this may be a bug in the SNMP implementation of the devices I am querying, but I guess it may also be a problem either with Net:SNMP or my code.

I've tried replacing the line:

my $oid = "$base_oid"."$oids{$version}".".$table_index";
with the hard-coded OID, however this gives the same result. And, as I mentioned above - it works fine with other OID's, so I don't really think the code is the problem.

Can anybody offer any insight or advice?

Thanks,
Darren :)


In reply to Net:SNMP get_table() method failing by McDarren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.