Commit da928f5a authored by Robert Ricci's avatar Robert Ricci

New script: interswitch

A simple little script to find links/lans that cross between switches,
and print them out (including which switches they use, and how many
members they have on each switch.)
parent f0fd5d86
......@@ -1119,7 +1119,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog db/webnodelog db/unixgroups \
db/dbcheck \
db/dbcheck db/interswitch\
ipod/GNUmakefile \
lib/GNUmakefile \
os/GNUmakefile os/split-image.sh os/imagezip/GNUmakefile \
......
......@@ -204,7 +204,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/dhcpd_makeconf db/nodelog db/webnodelog db/unixgroups \
db/dbcheck \
db/dbcheck db/interswitch\
ipod/GNUmakefile \
lib/GNUmakefile \
os/GNUmakefile os/split-image.sh os/imagezip/GNUmakefile \
......
......@@ -11,7 +11,7 @@ include $(OBJDIR)/Makeconf
BIN_SCRIPTS = nalloc nfree nodeip
SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
genelists genelists.proxy dhcpd_makeconf nodelog unixgroups \
dbcheck
dbcheck interswitch
LIBEXEC_SCRIPTS = webnodelog
LIB_SCRIPTS = libdb.pm
......
#!/usr/bin/perl
#
# Configure variables
#
use lib '@prefix@/lib';
use libdb;
#
# Get a list of all VLANs for swapped-in experiments
#
my $result = DBQueryFatal("SELECT eid, pid, virtual, members FROM vlans " .
"ORDER BY eid,pid,virtual");
while (my ($eid, $pid, $virtual, $members) = $result->fetchrow()) {
#
# Split apart the space-separated list of members
#
my @members = split /\s+/, $members;
my %switches = ();
foreach my $member (@members) {
my ($node,$if) = split /:/, $member;
#
# Find out which switch this interface is connected to
#
my $result2 = DBQueryFatal("SELECT node_id2 FROM wires AS w LEFT JOIN ".
"interfaces AS i ON w.node_id1=i.node_id AND w.card1=i.card " .
"WHERE node_id='$node' and iface='$if'");
# We assume only one response here!
my ($switch) = ($result2->fetchrow());
$switches{$switch}++;
}
#
# Report if more than one switch was found
#
if ((keys %switches) > 1) {
print "Link/LAN $virtual on $pid/$eid is on ",
join(", ", map { "$_ ($switches{$_} members)" } sort keys %switches),
"\n";
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment