From c9a0ac0a8dad07c8e01dbc126a52a669960d3407 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Thu, 26 Sep 2013 22:12:16 -0400 Subject: [PATCH] use ipAdEntAddr to get IP's rather than relying on index --- Netdisco/lib/App/Netdisco/Core/Discover.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index 8241cde3..b9c2f8c0 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -45,6 +45,7 @@ sub store_device { my ($device, $snmp) = @_; my $ip_index = $snmp->ip_index; + my $ip_table = $snmp->ip_table; my $interfaces = $snmp->interfaces; my $ip_netmask = $snmp->ip_netmask; @@ -58,16 +59,16 @@ sub store_device { # build device aliases suitable for DBIC my @aliases; foreach my $entry (keys %$ip_index) { - my $ip = NetAddr::IP::Lite->new($entry); + my $ip = NetAddr::IP::Lite->new($ip_table->{$entry}); my $addr = $ip->addr; next if $addr eq '0.0.0.0'; next if $ip->within($localnet); next if setting('ignore_private_nets') and $ip->is_rfc1918; - my $iid = $ip_index->{$addr}; + my $iid = $ip_index->{$entry}; my $port = $interfaces->{$iid}; - my $subnet = $ip_netmask->{$addr} + my $subnet = $ip_netmask->{$entry} ? NetAddr::IP::Lite->new($addr, $ip_netmask->{$addr})->network->cidr : undef;