aboutsummaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
Diffstat (limited to 'clients')
-rwxr-xr-xclients/build-linknets.pl18
-rw-r--r--clients/snmp.sql1
2 files changed, 19 insertions, 0 deletions
diff --git a/clients/build-linknets.pl b/clients/build-linknets.pl
index 9978ae8..0b07d33 100755
--- a/clients/build-linknets.pl
+++ b/clients/build-linknets.pl
@@ -16,6 +16,7 @@ $coregws->execute;
my %switch_id = (); # sysname -> switch database ID
my %loopbacks = (); # sysname -> primary address
+my %loop_ipv6 = (); # sysname -> primary address
my %map = (); # CIDR -> (sysname,ip)*
my %lldpneigh = (); # sysname -> sysname -> 1
@@ -35,6 +36,7 @@ while (my $ref = $coregws->fetchrow_hashref) {
my $ifs = $snmp->gettable('ifTable');
my $addrs = $snmp->gettable('ipAddrTable');
my $lldp = $snmp->gettable('lldpRemTable');
+ my $ipaddresstable = $snmp->gettable('ipAddressTable');
# Find all direct routes we have, and that we also have an address in.
# These are our linknet candidates.
@@ -63,6 +65,18 @@ while (my $ref = $coregws->fetchrow_hashref) {
last;
}
+ my %loopbacks_ipv6_this_switch = ();
+ for my $addr (values %$ipaddresstable) {
+ next if not $addr->{'ipAddressAddrType'} == 2; # Only IPv6 addresses please.
+ my $ifdescr = $ifs->{$addr->{'ipAddressIfIndex'}}->{'ifDescr'};
+ next unless $ifdescr =~ /^Loop/;
+ $loopbacks_ipv6_this_switch{$ifdescr} = nms::convert_ipv6( $addr->{'ipAddressAddr'} );
+ }
+ for my $if (sort keys %loopbacks_ipv6_this_switch) {
+ $loop_ipv6{$sysname} = $loopbacks_ipv6_this_switch{$if};
+ last;
+ }
+
# Find all LLDP neighbors.
for my $neigh (values %$lldp) {
$lldpneigh{$sysname}{$neigh->{'lldpRemSysName'}} = 1;
@@ -82,6 +96,10 @@ while (my ($sysname, $ip) = each %loopbacks) {
$dbh->do('UPDATE switches SET ip=? WHERE sysname=?',
undef, $ip, $sysname);
}
+while (my ($sysname, $ipv6) = each %loopbacks) {
+ $dbh->do('UPDATE switches SET second_ip=? WHERE sysname=?',
+ undef, $ipv6, $sysname);
+}
# Now go through each linknet candidate, and see if we can find any
# direct LLDP neighbors.
diff --git a/clients/snmp.sql b/clients/snmp.sql
index 47b4458..7e09313 100644
--- a/clients/snmp.sql
+++ b/clients/snmp.sql
@@ -6,6 +6,7 @@ create table switchtypes (
create table switches (
switch serial not null primary key,
ip inet not null,
+ secondary_ip inet,
sysname varchar not null,
switchtype varchar not null references switchtypes,
last_updated timestamp,