diff options
-rwxr-xr-x | examples/historical/clients/lldpdiscover.pl (renamed from clients/lldpdiscover.pl) | 0 | ||||
-rwxr-xr-x | examples/historical/clients/portnames.pl (renamed from clients/portnames.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/access_list.pl (renamed from mbd/access_list.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/derpspan.c (renamed from mbd/derpspan.c) | 0 | ||||
-rwxr-xr-x | examples/historical/mbd/generate-helper-list.pl (renamed from mbd/generate-helper-list.pl) | 0 | ||||
-rwxr-xr-x | examples/historical/mbd/make-mbd-nets.pl (renamed from mbd/make-mbd-nets.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/mbd-unicast-segfaulting.pl (renamed from mbd/mbd-unicast-segfaulting.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/mbd-unicast.pl (renamed from mbd/mbd-unicast.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/mbd.pl (renamed from mbd/mbd.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/mbd.pm (renamed from mbd/mbd.pm) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/nets.pl (renamed from mbd/nets.pl) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/packetpusher.c (renamed from mbd/packetpusher.c) | 0 | ||||
-rw-r--r-- | examples/historical/mbd/survey.pl (renamed from mbd/survey.pl) | 0 | ||||
-rwxr-xr-x | examples/historical/munin/backfill_total_network_traffic.pl (renamed from munin/backfill_total_network_traffic.pl) | 0 | ||||
-rwxr-xr-x | examples/historical/munin/clients_connected.pl (renamed from munin/clients_connected.pl) | 0 | ||||
-rwxr-xr-x | examples/historical/munin/total_network_traffic.pl (renamed from munin/total_network_traffic.pl) | 0 | ||||
-rw-r--r-- | examples/historical/tg15/netlist.txt (renamed from netlist.txt) | 0 | ||||
-rw-r--r-- | examples/historical/tg15/patchlist.txt (renamed from patchlist.txt) | 0 | ||||
-rw-r--r-- | examples/historical/tg15/patchlist_extras.txt (renamed from patchlist_extras.txt) | 0 | ||||
-rw-r--r-- | examples/historical/tg15/switches.txt (renamed from switches.txt) | 0 | ||||
-rw-r--r-- | examples/historical/tg15/switches_extras.txt (renamed from switches_extras.txt) | 0 | ||||
-rwxr-xr-x | examples/historical/tools/fetch-portlist.sh (renamed from tools/fetch-portlist.sh) | 0 | ||||
-rwxr-xr-x | examples/historical/tools/make-dummy-placement.sh (renamed from tools/make-dummy-placement.sh) | 0 | ||||
-rwxr-xr-x | examples/historical/tools/make-switch-placements.pl (renamed from tools/make-switch-placements.pl) | 0 | ||||
-rwxr-xr-x | examples/historical/tools/ping-graph.pl (renamed from tools/ping-graph.pl) | 0 | ||||
-rw-r--r-- | include/nms/util.pm | 137 | ||||
-rwxr-xr-x | tools/add_switches.txt.pl | 16 | ||||
-rwxr-xr-x | tools/lldp/dotnet.sh (renamed from tools/dotnet.sh) | 0 | ||||
-rwxr-xr-x | tools/lldp/draw-neighbors.pl (renamed from tools/draw-neighbors.pl) | 0 | ||||
-rwxr-xr-x | tools/lldp/lldpdiscover.pl (renamed from tools/lldpdiscover.pl) | 0 |
30 files changed, 153 insertions, 0 deletions
diff --git a/clients/lldpdiscover.pl b/examples/historical/clients/lldpdiscover.pl index 2f33bd9..2f33bd9 100755 --- a/clients/lldpdiscover.pl +++ b/examples/historical/clients/lldpdiscover.pl diff --git a/clients/portnames.pl b/examples/historical/clients/portnames.pl index 52e433a..52e433a 100755 --- a/clients/portnames.pl +++ b/examples/historical/clients/portnames.pl diff --git a/mbd/access_list.pl b/examples/historical/mbd/access_list.pl index 89a8182..89a8182 100644 --- a/mbd/access_list.pl +++ b/examples/historical/mbd/access_list.pl diff --git a/mbd/derpspan.c b/examples/historical/mbd/derpspan.c index b9fb362..b9fb362 100644 --- a/mbd/derpspan.c +++ b/examples/historical/mbd/derpspan.c diff --git a/mbd/generate-helper-list.pl b/examples/historical/mbd/generate-helper-list.pl index fd89475..fd89475 100755 --- a/mbd/generate-helper-list.pl +++ b/examples/historical/mbd/generate-helper-list.pl diff --git a/mbd/make-mbd-nets.pl b/examples/historical/mbd/make-mbd-nets.pl index 7f6ec97..7f6ec97 100755 --- a/mbd/make-mbd-nets.pl +++ b/examples/historical/mbd/make-mbd-nets.pl diff --git a/mbd/mbd-unicast-segfaulting.pl b/examples/historical/mbd/mbd-unicast-segfaulting.pl index c167511..c167511 100644 --- a/mbd/mbd-unicast-segfaulting.pl +++ b/examples/historical/mbd/mbd-unicast-segfaulting.pl diff --git a/mbd/mbd-unicast.pl b/examples/historical/mbd/mbd-unicast.pl index 6e63dee..6e63dee 100644 --- a/mbd/mbd-unicast.pl +++ b/examples/historical/mbd/mbd-unicast.pl diff --git a/mbd/mbd.pl b/examples/historical/mbd/mbd.pl index 065e76c..065e76c 100644 --- a/mbd/mbd.pl +++ b/examples/historical/mbd/mbd.pl diff --git a/mbd/mbd.pm b/examples/historical/mbd/mbd.pm index b844e5b..b844e5b 100644 --- a/mbd/mbd.pm +++ b/examples/historical/mbd/mbd.pm diff --git a/mbd/nets.pl b/examples/historical/mbd/nets.pl index 3298657..3298657 100644 --- a/mbd/nets.pl +++ b/examples/historical/mbd/nets.pl diff --git a/mbd/packetpusher.c b/examples/historical/mbd/packetpusher.c index c21a084..c21a084 100644 --- a/mbd/packetpusher.c +++ b/examples/historical/mbd/packetpusher.c diff --git a/mbd/survey.pl b/examples/historical/mbd/survey.pl index be33038..be33038 100644 --- a/mbd/survey.pl +++ b/examples/historical/mbd/survey.pl diff --git a/munin/backfill_total_network_traffic.pl b/examples/historical/munin/backfill_total_network_traffic.pl index 000b0d5..000b0d5 100755 --- a/munin/backfill_total_network_traffic.pl +++ b/examples/historical/munin/backfill_total_network_traffic.pl diff --git a/munin/clients_connected.pl b/examples/historical/munin/clients_connected.pl index 5301c63..5301c63 100755 --- a/munin/clients_connected.pl +++ b/examples/historical/munin/clients_connected.pl diff --git a/munin/total_network_traffic.pl b/examples/historical/munin/total_network_traffic.pl index 2c0799b..2c0799b 100755 --- a/munin/total_network_traffic.pl +++ b/examples/historical/munin/total_network_traffic.pl diff --git a/netlist.txt b/examples/historical/tg15/netlist.txt index 67f2c11..67f2c11 100644 --- a/netlist.txt +++ b/examples/historical/tg15/netlist.txt diff --git a/patchlist.txt b/examples/historical/tg15/patchlist.txt index 3f73092..3f73092 100644 --- a/patchlist.txt +++ b/examples/historical/tg15/patchlist.txt diff --git a/patchlist_extras.txt b/examples/historical/tg15/patchlist_extras.txt index f7b0fb2..f7b0fb2 100644 --- a/patchlist_extras.txt +++ b/examples/historical/tg15/patchlist_extras.txt diff --git a/switches.txt b/examples/historical/tg15/switches.txt index c9ea727..c9ea727 100644 --- a/switches.txt +++ b/examples/historical/tg15/switches.txt diff --git a/switches_extras.txt b/examples/historical/tg15/switches_extras.txt index afb3415..afb3415 100644 --- a/switches_extras.txt +++ b/examples/historical/tg15/switches_extras.txt diff --git a/tools/fetch-portlist.sh b/examples/historical/tools/fetch-portlist.sh index 978b590..978b590 100755 --- a/tools/fetch-portlist.sh +++ b/examples/historical/tools/fetch-portlist.sh diff --git a/tools/make-dummy-placement.sh b/examples/historical/tools/make-dummy-placement.sh index 192e3d3..192e3d3 100755 --- a/tools/make-dummy-placement.sh +++ b/examples/historical/tools/make-dummy-placement.sh diff --git a/tools/make-switch-placements.pl b/examples/historical/tools/make-switch-placements.pl index efacfcc..efacfcc 100755 --- a/tools/make-switch-placements.pl +++ b/examples/historical/tools/make-switch-placements.pl diff --git a/tools/ping-graph.pl b/examples/historical/tools/ping-graph.pl index 2cd6996..2cd6996 100755 --- a/tools/ping-graph.pl +++ b/examples/historical/tools/ping-graph.pl diff --git a/include/nms/util.pm b/include/nms/util.pm new file mode 100644 index 0000000..e1ebaa3 --- /dev/null +++ b/include/nms/util.pm @@ -0,0 +1,137 @@ +#! /usr/bin/perl +use strict; +use warnings; +package nms::util; +use Data::Dumper; + +use base 'Exporter'; +our @EXPORT = qw(guess_placement parse_switches_txt parse_switches parse_switch); + +# Parse a single switches.txt-formatted switch +sub parse_switch { + my ($switch, $subnet4, $subnet6, $mgtmt4, $mgtmt6, $lolid, $distro) = split(/ /); + my %foo = guess_placement($switch); + my %ret = ( + 'name' => "$switch", + 'subnet4' => "$subnet4", + 'subnet6' => "$subnet6", + 'mgtmt4' => "$mgtmt4", + 'mgtmt6' => "$mgtmt6", + 'lolid' => "$lolid", + 'distro' => "$distro" + ); + %{$ret{'placement_guess'}} = guess_placement($switch); + return %ret; +} + +# Parses a switches_txt given as a filehandle on $_[0] +# (e.g.: parse_switches_txt(*STDIN) or parse_switches_txt(whatever). +sub parse_switches_txt { + my $fh = $_[0]; + my %switches = (); + while(<$fh>) { + chomp; + my %switch = parse_switch($_); + %{$switches{$switch{'name'}}} = %switch; + } + return %switches; +} + +# Parses switches in switches.txt format given as $_[0]. +# E.g: parse_switches("e1-3 88.92.0.0/26 2a06:5840:0a::/64 88.92.54.2/26 2a06:5840:54a::2/64 1013 distro0") +sub parse_switches { + my %switches = (); + my $txt = $_[0]; + foreach (split("\n",$txt)) { + chomp; + my %switch = parse_switch($_); + %{$switches{$switch{'name'}}} = %switch; + } + return %switches; +} + +# Guesses placement from name to get a starting point +# Largely courtesy of Knuta +sub guess_placement { + my ($x, $y, $xx, $yy); + + my $name = $_[0]; + my $src = "unknown"; + if ($name =~ /^e\d+-\d+$/) { + $name =~ /e(\d+)-(\d+)/; + my ($e, $s) = ($1, $2); + $src = "main"; + + $x = int(232 + (($e-1)/2) * 31.1); + $y = undef; + + $x += 14 if ($e >= 17); + $x += 14 if ($e >= 29); + $x += 14 if ($e >= 45); + $x += 14 if ($e >= 63); + + if ($s > 2) { + $y = 405 - 120 * ($s-2); + } else { + $y = 689 - 120 * ($s); + } + + $xx = $x + 16; + $yy = $y + 120; + + # Justeringer + $y += 45 if $name eq "e1-4"; + $y += 20 if $name eq "e3-4"; + $y += 15 if $name eq "e5-4"; + $yy -= 25 if $name eq "e11-1"; + + #$yy -= 14 if $name eq "e77-1"; + #$yy -= 28 if $name eq "e79-1"; + #$yy -= 15 if $name eq "e81-1"; + #$yy -= 56 if $name eq "e83-1"; + } elsif ($name =~ /^sw(\d+)-creativia$/) { + my ($s) = ($1); + $src = "creativia"; + $x = 1535; + $y = int(130 + 32.2 * $s); + $yy = $y + 20; + if ($s == 1) { + $xx = $x + 70; + } elsif ($s == 2) { + $xx = $x + 90; + } elsif ($s == 3) { + $xx = $x + 102; + } else { + $xx = $x + 142; + } + + } elsif ($name =~ /^crew(\d+)-(\d+)$/) { + my ($s, $n) = ($1, $2); + $src = "crew"; + $x = 1023 + 45 * $n; + $y = int(329 + 20.5 * $s); + $xx = $x + 45; + $yy = $y + 14; + + if ($s == 1 && $n == 1) { + $xx += 25; + } + } else { + # Fallback to have _some_ position + $src = "random"; + $x = int(rand(500)); + $y = int(rand(500)); + $xx = $x + 20; + $yy = $y + 130; + }; + + + my %box = ( + 'src' => "$src", + 'x1' => $x, + 'y1' => $y, + 'xx' => $xx, + 'yy' => $yy + ); + return %box; +} diff --git a/tools/add_switches.txt.pl b/tools/add_switches.txt.pl new file mode 100755 index 0000000..283eeea --- /dev/null +++ b/tools/add_switches.txt.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl +# Usage: ./add_switches.txt.pl < switches.txt > switches.json +# +# Parses switches.txt into json currently just throws it to stdout +# +# Actually adding them to a DB comes later. + +use strict; +use warnings; +use Data::Dumper; +use lib '../include'; +use nms::util; + +my %switches = parse_switches_txt(*STDIN); + +print Dumper(\%switches); diff --git a/tools/dotnet.sh b/tools/lldp/dotnet.sh index 5c1b369..5c1b369 100755 --- a/tools/dotnet.sh +++ b/tools/lldp/dotnet.sh diff --git a/tools/draw-neighbors.pl b/tools/lldp/draw-neighbors.pl index 323e676..323e676 100755 --- a/tools/draw-neighbors.pl +++ b/tools/lldp/draw-neighbors.pl diff --git a/tools/lldpdiscover.pl b/tools/lldp/lldpdiscover.pl index f3df093..f3df093 100755 --- a/tools/lldpdiscover.pl +++ b/tools/lldp/lldpdiscover.pl |