aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2016-02-26 13:05:31 +0000
committerKristian Lyngstol <kly@kly.no>2016-02-26 13:05:31 +0000
commit885156ee6a26ed047bba3f90541eaab92b65d758 (patch)
treee8a70cd6bca09641efac0c64c4c20d27efab2bda /tools
parentc6997a4810e09619e9018c91d163f3f38b17212c (diff)
parent3dae75bde90aecc0cef2e3496f3565dcb3eeec0c (diff)
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'tools')
-rwxr-xr-xtools/add_switches.txt.pl16
-rwxr-xr-xtools/fetch-portlist.sh42
-rwxr-xr-xtools/lldp/dotnet.sh (renamed from tools/dotnet.sh)0
-rwxr-xr-xtools/lldp/draw-neighbors.pl (renamed from tools/draw-neighbors.pl)0
-rwxr-xr-xtools/lldp/lldpdiscover.pl (renamed from tools/lldpdiscover.pl)0
-rwxr-xr-xtools/make-dummy-placement.sh12
-rwxr-xr-xtools/make-switch-placements.pl86
-rwxr-xr-xtools/ping-graph.pl62
8 files changed, 16 insertions, 202 deletions
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/fetch-portlist.sh b/tools/fetch-portlist.sh
deleted file mode 100755
index 978b590..0000000
--- a/tools/fetch-portlist.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-print_range() {
- FIRST=$1
- LAST=$2
- if [ "$1" = "$2" ]; then
- echo $FIRST
- else
- echo $FIRST-$LAST
- fi
-}
-
-walk_ports() {
- IP=$1
- COMMUNITY=$2
-
- FIRST_PORT=
- LAST_PORT=
-
- for PORT in $( snmpwalk -Os -m IF-MIB -v 2c -c $COMMUNITY $IP ifDescr 2>/dev/null | grep -E ' ge|et|xe' | cut -d. -f2 | cut -d" " -f1 ); do
- if ! snmpget -m IF-MIB -v 2c -c $COMMUNITY $IP ifHCInOctets.$PORT 2>/dev/null | grep -q 'No Such Instance'; then
- if [ "$LAST_PORT" ] && [ `expr $LAST_PORT + 1` = $PORT ]; then
- LAST_PORT=$PORT
- else
- if [ "$LAST_PORT" ]; then
- print_range $FIRST_PORT $LAST_PORT
- fi
- FIRST_PORT=$PORT
- LAST_PORT=$PORT
- fi
- fi
- done
-
- print_range $FIRST_PORT $LAST_PORT
-}
-
-COMMUNITY=$1
-IP=$2
-SYSNAME=$3
-PORTS=$( walk_ports $IP $COMMUNITY | tr "\n" "," | sed 's/,$//' )
-
-echo "insert into switchtypes values ('$SYSNAME','$PORTS',true);"
-echo "insert into switches values (default,'$IP','$SYSNAME','$SYSNAME',null,default, default, '1 minute', '$COMMUNITY');"
-
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
diff --git a/tools/make-dummy-placement.sh b/tools/make-dummy-placement.sh
deleted file mode 100755
index 192e3d3..0000000
--- a/tools/make-dummy-placement.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-# Generate a random placement-entry insert for a named switch (convenient
-# if you manually add a switch with no placement)
-
-for a in $* ; do
-X=$(( $RANDOM % 500 ))
-Y=$(( $RANDOM % 500 ))
-X1=$(( $X + 20 ))
-Y1=$(( $Y + 130 ))
-echo "insert into placements select switch, box '(($X,$Y),($X1,$Y1))' from switches where sysname = '$a';"
-done
diff --git a/tools/make-switch-placements.pl b/tools/make-switch-placements.pl
deleted file mode 100755
index efacfcc..0000000
--- a/tools/make-switch-placements.pl
+++ /dev/null
@@ -1,86 +0,0 @@
-#! /usr/bin/perl
-use strict;
-use warnings;
-
-my $switchtype = "ex2200";
-
-print "begin;\n";
-print "delete from placements where switch in (select switch from switches where switchtype = '$switchtype' and (sysname like 'e%') or sysname like '%creativia%');\n";
-
-my %ip;
-my $i = 1;
-while (<STDIN>) {
- chomp;
- my @info = split(/ /);
-
- if (scalar @info < 5) {
- die "Unknown line: $_";
- }
- my ($x, $y, $xx, $yy);
-
- my $name = $info[0];
- if ($name =~ /^e\d+-\d+$/) {
- $name =~ /e(\d+)-(\d+)/;
- my ($e, $s) = ($1, $2);
-
- $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);
- $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);
- $x = 1023 + 45 * $n;
- $y = int(329 + 20.5 * $s);
- $xx = $x + 45;
- $yy = $y + 14;
-
- if ($s == 1 && $n == 1) {
- $xx += 25;
- }
- } else {
- next;
- }
-
- print "insert into placements select switch, box '(($x,$y),($xx,$yy))' from switches where sysname = '$name';\n";
- $i++;
-}
-
-print "end;\n";
diff --git a/tools/ping-graph.pl b/tools/ping-graph.pl
deleted file mode 100755
index 2cd6996..0000000
--- a/tools/ping-graph.pl
+++ /dev/null
@@ -1,62 +0,0 @@
-#! /usr/bin/perl
-
-# Makes latency-against-time graphs, one per switch.
-
-use warnings;
-use strict;
-use DBI;
-use lib '../include';
-use nms;
-
-BEGIN {
- require "../include/config.pm";
- eval {
- require "../include/config.local.pm";
- };
-}
-
-my $dbh = db_connect();
-my $switches = $dbh->selectall_hashref('SELECT sysname,switch FROM switches ORDER BY sysname', 'sysname');
-if (1) {
- my %switchfds = ();
- while (my ($sysname, $switch) = each %$switches) {
- print "$sysname -> $switch->{switch}\n";
- open my $fh, ">", "$sysname.txt"
- or die "$sysname.txt: $!";
- $switchfds{$switch->{'switch'}} = $fh;
- }
-
- my $q = $dbh->prepare('SELECT switch,EXTRACT(EPOCH FROM updated),latency_ms FROM ping');
- $q->execute;
-
- my $i = 0;
- while (my $ref = $q->fetchrow_arrayref) {
- next if (!defined($ref->[2]));
- my $fh = $switchfds{$ref->[0]};
- next if (!defined($fh));
- print $fh $ref->[1], " ", $ref->[2], "\n";
- if (++$i % 1000000 == 0) {
- printf "%dM records...\n", int($i / 1000000);
- }
- }
-
- while (my ($sysname, $switch) = each %$switches) {
- close $switchfds{$switch->{'switch'}};
- }
-}
-
-while (my ($sysname, $switch) = each %$switches) {
- print "$sysname -> $switch->{switch}\n";
- open my $gnuplot, "|-", "gnuplot"
- or die "gnuplot: $!";
- print $gnuplot <<"EOF";
-set timefmt "%s"
-set xdata time
-set format x "%d/%m %H:%M"
-set term png size 1280,720
-set output '$sysname.png'
-set yrange [0:200]
-plot "$sysname.txt" using (int(\$1)):2 ps 0.1
-EOF
- close $gnuplot;
-}