But if you'd posted the code 3 days ago as asked, your problem would probably be fixed by
now.
Oh? :P The problem with that is that the code is over 100K and there's
really nothing wrong with my code, I mean I've been staring at it for weeks
and I have been doing this for many years.
I think I've found something with my rebuild effort. A code block that
when commented out, the script doesn't leak. I really defy anyone to
find anything syntacticly wrong with this code. :)
## all in ifpoll
local %routes = ();
my $result6;
## device can have CIDR or non-CIDR routing
$result6 = $$session->get_entries(-columns => [$ipCidrRouteIfIndex, $i
+pCidrRouteProto, $ipCidrRouteType ]);
$result6 = $$session->get_entries(-columns => [$ipRouteNextHop, $ipRou
+teIfIndex, $ipRouteMask, $ipRouteProto, $ipRouteType]) unless %$resul
+t6;
if (!defined($result6)) {
printf(STDERR "ERROR(routes): %s %s.\n", $devarg, $$session->err
+or);
}
local $testkey = each %$result6;
if ($testkey =~ m/^\Q1.3.6.1.2.1.4.24.4.1.\E/o) {
print "Entering CIDR parsing\n";
foreach $key (keys %$result6) {
if ($key =~ m/^\Q$ipCidrRouteProto\E/o) {
my @temp = $key =~ m/^\Q$ipCidrRouteProto\E\.(\d{1,3}\.\d{
+1,3}\.\d{1,3}\.\d{1,3})\.(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.0\.(\d
+{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/o;
my $id = join ".", @temp;
$routes{$id}{"proto"} = ${$result6}{$key};
}
elsif ($key =~ m/^\Q$ipCidrRouteType\E/o) {
my @temp = $key =~ m/^\Q$ipCidrRouteType\E\.(\d{1,3}\.\d{1
+,3}\.\d{1,3}\.\d{1,3})\.(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.0\.(\d{
+1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/o;
my $id = join ".", @temp;
$routes{$id}{"type"} = ${$result6}{$key};
}
elsif ($key =~ m/^\Q$ipCidrRouteIfIndex\E/o) {
# dest
+network dest mask
+ next hop
my @temp = $key =~ m/^\Q$ipCidrRouteIfIndex\E\.(\d{1,3}\.\
+d{1,3}\.\d{1,3}\.\d{1,3})\.(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.0\.(
+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/o;
my $id = join ".", @temp;
$routes{$id}{"net"} = $temp[0];
$routes{$id}{"mask"} = $temp[1];
$routes{$id}{"nexthop"} = $temp[2];
$routes{$id}{"ifindex"} = ${$result6}{$key};
}
}
}
elsif ($testkey =~ m/^\Q1.3.6.1.2.1.4.21.1.\E/) {
print "Entering non CIDR parsing\n";
foreach $key (keys %$result6) {
my $index;
if (($index) = $key =~ m/^\Q$ipRouteNextHop\E\.(.+)/o) {
#print "Found next hop ${$result6}{$key} for $index in $ke
+y\n";
$routes{$index}{"nexthop"} = ${$result6}{$key} ; #|| "NULL
+" or die "route assignment failed\n";
$routes{$index}{"net"} = $index;
}
elsif (($index) = $key =~ m/^\Q$ipRouteIfIndex\E\.(.+)/o) {
$routes{$index}{"ifindex"} = ${$result6}{$key}; # || "NULL
+" or die "route assignment failed\n";
#print "Found destination ${$result6}{$key} for $index in
+$key\n";
}
elsif (($index) = $key =~ m/^\Q$ipRouteMask\E\.(.+)/o) {
$routes{$index}{"mask"} = ${$result6}{$key}; # || "NULL" o
+r die "route assignment failed\n";
#print "Found mask${$result6}{$key} for $index in $key\n";
}
elsif (($index) = $key =~ m/^\Q$ipRouteProto\E\.(.+)/o) {
$routes{$index}{"proto"} = ${$result6}{$key}; # || "NULL"
+or die "route assignment failed\n";
#print "Found mask${$result6}{$key} for $index in $key\n";
}
elsif (($index) = $key =~ m/^\Q$ipRouteType\E\.(.+)/o) {
$routes{$index}{"type"} = ${$result6}{$key}; # || "NULL" o
+r die "route assignment failed\n";
#print "Found mask${$result6}{$key} for $index in $key\n";
}
}
}
%{$datahash{"routes"}} = %routes;
$session is a reference to the Net::SNMP object. $result6 is a
reference to an anonymous hash containing the SNMP return values.
Comment this all out and no memory leak.
Any ideas? |