found Bug in older Net-SNMP (or SNMP.pm.)

[email protected]
Newsgroups gmane.network.net-snmp.user
Organization http://freemail.web.de/
Message-ID <[email protected]>
Hello there,

I got a terrible headache collecting some instance specific data from an Cisco Router using SNMPv2c, GET, NET-SNMP (Perl SNMP.pm) V.5.1.4 on an AIX 5.3.

Some time it works fine, but then there are errors. Perl canŽt find the responsed data. 

I traced the last 5 Days while looking for bugs in my code and found a strange behavior thanks to iptrace, wireshark and $SNMP::debugging =3.

It looks like if Net-SNMP v.5.1.4 sends a get request (say with request-id 10) waiting for a receive and "somehow" sees an earlier responsed packet (say with request-id 8).
Instead of comparing the request-id, the varbinds item name or atlast the timestamp, this response is taken.

The error appears randomly (using get/Bulkwalk/getbulk) too. 

If my community wasnŽt spoiled all over the dump, I would hand it to you. It put a tiny&dirty skript together which will replicate the error.

Thanks,

Bastian

 

 

 

###################################################use warnings; use SNMP;
use SNMP::Multi; my @data = <DATA>;
my @routers = qw (); #place routers
my @mib = qw ( ); #place mibs see list after __DATA__ my $nonrep = 0;
my $rep = 0;
my @nonrep = ();
my @rep = (); 
foreach my $ids ( @mib ) {
 foreach my $dainline ( @data ) {
 $da =~ s/\s+//;
 print "$da\n";
 if ($ids =~ /$dainline\.\d/) {
 push (@nonrep,$ids);
 print "found a nonrep\n";
 $nonrep++;
 
 } elsif ($m =~ /$dainline\b/) {
 push (@rep,$ids);
 print "found a rep\n";
 $rep++;
 } 
 } 
} my $methode = undef; if ($nonrep){
 @mib = ();
 push (@mib,@nonrep);
 $methode = 'get';
 &frag;
 $nonrep=0;
} if ($rep) {
 @mib = ();
 push (@mib,@rep);
 $methode = 'bulkwalk';
 &frag; 
} 
$nonrep = @nonrep;
print "Found $rep Reps and $nonrep Nonreps.\nUsing Methode: $methode!\n";
@mib=();
@nonrep=();
@rep=(); sub frag() {
 my $mib = undef;
 my $lastdefhe = 0;
 my $oid = 1;
 
 my $requested = SNMP::Multi::VarReq->new (
 nonrepeaters => $nonrep,
 hosts => [ @routers ],
 vars => [ $mib[0] ],
 ); 
 while (defined ($mib[$oid])) {
 print "ask for $mib[$oid]\n";
 $requested->add( vars => [ $mib[$oid] ] );
 $oid++;
 $lastdefhe++;
 }
 
 #print "Vars to request $lastdefhe\n";
 
my $session = SNMP::Multi->new (
 Method => "$methode",
 MaxSessions => 100,
 PduPacking => 32,
 Community => "xxx",
 Version => '2c',
 Timeout => 5,
 Retries => 3,
) or warn "$SNMP::Multi::error \n";
 
 $session->request ($requested) or print $session->error;
 
 my $resp = $session->execute(15) or print "Execute: $SNMP::Multi::error\n"; 
 
 undef %reprouters;
 
 if (defined $resp) {
 print "got response\n";
 for my $host2 ($resp->hosts()) {
 print "host $host2\n";
 $reprouters{$host2} = $host2;
 }
 }
 
 # *** Feststellen ob welche fehlen ***
 for $host3 (@routers) {
 if (!$reprouters{$host3}) {
 $tomdatum = localtime($now);
 print LOG "$now: $tomdatum $host3 hat nicht geantwortet\n";
 print "$now: $tomdatum $host3 hat nicht geantwortet.\n";
 }
 }
 
 if (defined $resp) {
 for my $host ($resp->hosts()) {
 print "looking host $host resultes\n";
 # *** Ist dieser host im Ergebnis vorhanden ***
 for my $result ($host->results()) {
 print "$result host resultes\n";
 if (defined $result) {
 if ($result && $result->error()) {
 print "got errors\n";
 # *** no value received for this*** 
 next; 
 } else {
 print "no errors\n";
 for my $varlist ($result->varlists()) {
 print "Varlist:\n", map {"\t" . $_->fmt() . "\n" } @$varlist;
 print "working $varlist list requestet with $methode\n";
 foreach (@{$varlist}) { foreach (@$_) {print "$_ \n";};};
 }
 }
 }
 }
 }
 } 
 }
} #sysObjectID 1.3.6.1.2.1.1.2 .0
#sysUpTime 1.3.6.1.2.1.1.3 .0
#tcpCurrEstab 1.3.6.1.2.1.6.9 .0
#ipMRouteHCOctets 1.3.6.1.2.1.83.1.1.2.1.16
#ipMRouteUpTime 1.3.6.1.2.1.83.1.1.2.1.6 
#ifLastChange 1.3.6.1.2.1.2.2.1.9 
#ifHCInOctets 1.3.6.1.2.1.31.1.1.1.6
#ifHCInUcastPkts 1.3.6.1.2.1.31.1.1.1.7
#ifHCInMulticastPkts 1.3.6.1.2.1.31.1.1.1.8
#ifHCInBroadcastPkts 1.3.6.1.2.1.31.1.1.1.9
#ifHCOutOctets 1.3.6.1.2.1.31.1.1.1.10
#ifHCOutUcastPkts 1.3.6.1.2.1.31.1.1.1.11
#ifHCOutMulticastPkts 1.3.6.1.2.1.31.1.1.1.12
#ifHCOutBroadcastPkts 1.3.6.1.2.1.31.1.1.1.13
#ifHighSpeed 1.3.6.1.2.1.31.1.1.1.15
#ipMRouteInterfaceHCInMcastOctets 1.3.6.1.2.1.83.1.1.4.1.7
#ipMRouteInterfaceHCOutMcastOctets 1.3.6.1.2.1.83.1.1.4.1.8
#casAuthenResponseTime 1.3.6.1.4.1.9.10.56.1.2.1.1.6
#casAcctResponseTime 1.3.6.1.4.1.9.10.56.1.2.1.1.22
__DATA__
1.3.6.1.2.1.1.2
1.3.6.1.2.1.1.3
1.3.6.1.2.1.6.9
1.3.6.1.2.1.83.1.1.4.1.7
1.3.6.1.2.1.2.2.1.9
1.3.6.1.2.1.31.1.1.1.6
1.3.6.1.2.1.31.1.1.1.7
1.3.6.1.2.1.31.1.1.1.8
1.3.6.1.2.1.31.1.1.1.9
1.3.6.1.2.1.31.1.1.1.10
1.3.6.1.2.1.31.1.1.1.11
1.3.6.1.2.1.31.1.1.1.12
1.3.6.1.2.1.31.1.1.1.13
1.3.6.1.2.1.31.1.1.1.15
1.3.6.1.2.1.83.1.1.4.1.7
1.3.6.1.2.1.83.1.1.4.1.8
1.3.6.1.2.1.83.1.1.2.1.6
1.3.6.1.4.1.9.10.56.1.2.1.1.6
1.3.6.1.4.1.9.10.56.1.2.1.1.22#########################################################

 


	
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate 
kostenlos testen. *http://www.pc-sicherheit.web.de/startseite/?mc=022220* [http://www.pc-sicherheit.web.de/startseite/?mc=022220]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.