diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-06-30 19:03:45 +0200 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-06-30 19:03:45 +0200 |
commit | 2bd867e1cd956f97ed595365ee9ea5228be27ec7 (patch) | |
tree | 6bd6ea44cbb66974bcc97bae37595cffe903c5e6 /extras/tools | |
parent | 55148e1e558d6f0bc97bc8f6bc2933652ca2468d (diff) |
lolwhat tweaks
Diffstat (limited to 'extras/tools')
-rwxr-xr-x | extras/tools/lldp/lolwhat.pl | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/extras/tools/lldp/lolwhat.pl b/extras/tools/lldp/lolwhat.pl index 64e0140..e9f15e1 100755 --- a/extras/tools/lldp/lolwhat.pl +++ b/extras/tools/lldp/lolwhat.pl @@ -48,11 +48,13 @@ mylog("Polling initial systems"); logindent(1); foreach my $target (@ips) { probe_sys($target, $cmdline_community); + pad_snmp_results(); } logindent(-1); peerdetect(); +pad_snmp_results(); # List of chassis IDs checked. # Note that we deliberately don't add the chassis id's from systems prboed @@ -72,6 +74,7 @@ while (scalar keys %lldppeers > scalar @chassis_ids_checked) { probe_sys($lldppeers{$id}{ip}, $cmdline_community); push @chassis_ids_checked,$id; } + pad_snmp_results(); peerdetect(); logindent(-1); } @@ -79,6 +82,7 @@ mylog("Probing complete. Trying to make road in the velling"); pad_snmp_results(); deduplicate(); +pad_snmp_results(); populate_lldpmap(); populate_ipmap(); @@ -100,7 +104,9 @@ sub compare_targets_depth { if (!defined($one) and !defined($two)) { next; } - if ($one ne $two) { + if (!defined($one) or !defined($two)) { + $res++; + } elsif ($one ne $two) { $res++; } else { if ($one ne "" and $two ne "") { @@ -364,7 +370,7 @@ sub deduplicate my $sysname = $snmpresults{$ip}; if (defined($syscollisions{$sysname})) { mylog("Can't really fix $ip because there's also a sysname collision for that sysname"); - $snmpresults{$ip}{lldpLocChassisId} = undef; + #$snmpresults{$ip}{lldpLocChassisId} = undef; } elsif (defined($remmap{$sysname})) { if ($remmap{$sysname} eq $snmpresults{$ip}{lldpLocChassisId}) { mylog("Couldn't fix $ip / $sysname. The extrapolated chassis id seen from remote is the same as the colliding one.... "); @@ -402,8 +408,16 @@ sub parse_snmp $result{sysDescr} = $snmp->{sysDescr}; my $chassis_id = nms::convert_mac($snmp->{lldpLocChassisId}); if (defined($chassis_id)) { - $result{lldpLocChassisId} = $chassis_id; - mylog("Chassis id: $chassis_id"); + if (defined($result{lldpLocChassisId})) { + if ($result{lldpLocChassisId} eq $chassis_id) { + mylog("Chassis id matched remote..."); + } else { + mylog("Bad chassis id.... Fudge. Ignoring direct result."); + } + } else { + $result{lldpLocChassisId} = $chassis_id; + mylog("Chassis id: $chassis_id"); + } } else { mylog("XXX: No lldpLocChassisId found. Bummer. Enable LLDP?"); } @@ -573,7 +587,7 @@ sub mylog { sub probe_sys { my ($target, $community) = @_; - if (defined($snmpresults{$target})) { + if (defined($snmpresults{$target}) and defined($snmpresults{$target}{'probed'})) { mylog("Already probed $target. Skipping."); return; } @@ -582,6 +596,7 @@ sub probe_sys return; } my $snmp = get_snmp_data($target, $community); + $snmpresults{$target}{'probed'} = 1; if (!defined($snmp)) { return; } @@ -590,6 +605,7 @@ sub probe_sys return; } $snmpresults{$target} = $parsed; + $snmpresults{$target}{'probed'} = 1; } sub populate_lldpmap { |