Subject: | SNMP unable to process certain OIDs (exception || undef) |
Date: | Thu, 13 Sep 2007 13:16:33 +0200 |
To: | bug-SNMP [...] rt.cpan.org |
From: | Peter Rabbitson <rabbit+bugs [...] rabbit.us> |
Hi,
Attached are a simple test script and the output when being run against
a Cisco Catalyst 2950 switch. Net::SNMP seems to be doing just great,
while SNMP fails on 3 out of 4 polls. Is this intended behavior and
Net::SNMP is supposed to be a superset of SNMP? Or is this a bug?
Thanks
Peter
#!/usr/bin/perl
use warnings;
use strict;
use Net::SNMP;
use SNMP;
use Data::Dumper;
$Data::Dumper::Useqq = 1;
$| = 1;
my $switchaddr = '192.168.58.254';
my $community = 'snmp_poll';
my $snmp = SNMP::Session->new (
DestHost => $switchaddr,
Community => $community,
Version => '2c',
) or die "Unable to connect to $switchaddr via SNMP\n";
my $net_snmp = Net::SNMP->session (
-hostname => $switchaddr,
-version => '2c',
-community => $community,
) or die "Unable to connect to $switchaddr via Net::SNMP\n";
show_modules();
for my $oid (qw/
.1.3.6.1.2.1.1
.1.3.6.1.2.1.2.2
.1.3.6.1.2.1.16.19
.1.3.6.1.2.1.17.4.3.1.1
/) {
my $response;
print "\nTrying Net::SNMP->get_table on $oid\n=========================\n";
eval { $response = $net_snmp->get_table (-baseoid => $oid) };
if ($@) {
print "FAILED: $@\n";
}
else {
print Dumper $response;
}
print "\nTrying SNMP->gettable on $oid\n=========================\n";
eval { $response = $snmp->gettable ($oid) };
if ($@) {
print "FAILED: $@\n";
}
else {
print Dumper $response;
}
}
sub show_modules {
no strict 'refs';
printf "Perl Version: %vd\n\nCurrently loaded modules:\n===========================\n", $^V;
for my $mod (sort keys %INC) {
$mod =~ s/\.pm$// or next;
$mod =~ s!/!::!g;
printf "%s => %s\n", $mod, $mod->VERSION || 'Unknown';
}
print "\n";
}
Message body not shown because it is not plain text.