diff options
-rwxr-xr-x | clients/ping.pl | 30 | ||||
-rwxr-xr-x | clients/update-public-nms.sh | 12 | ||||
-rw-r--r-- | netlist.txt | 3 | ||||
-rw-r--r-- | sql/nms.sql | 4 | ||||
-rw-r--r-- | web/nms-public.gathering.org/dhcp.html | 10 | ||||
-rw-r--r-- | web/nms-public.gathering.org/index.html | 15 | ||||
-rw-r--r-- | web/nms-public.gathering.org/led.txt | 256 | ||||
-rw-r--r-- | web/nms-public.gathering.org/nettkart-dhcp.png | bin | 203313 -> 0 bytes | |||
-rw-r--r-- | web/nms-public.gathering.org/nettkart-trafikk.png | bin | 291454 -> 0 bytes | |||
-rw-r--r-- | web/nms-public.gathering.org/trafikk.html | 10 | ||||
-rwxr-xr-x | web/nms.gathering.org/ping-json.pl | 11 | ||||
-rw-r--r-- | web/nms.gathering.org/ping.js | 19 |
12 files changed, 62 insertions, 308 deletions
diff --git a/clients/ping.pl b/clients/ping.pl index 6968b4d..b41febd 100755 --- a/clients/ping.pl +++ b/clients/ping.pl @@ -13,7 +13,7 @@ my $dbh = nms::db_connect(); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; -my $q = $dbh->prepare("SELECT switch,ip FROM switches WHERE ip<>'127.0.0.1'"); +my $q = $dbh->prepare("SELECT switch,ip,secondary_ip FROM switches WHERE ip<>'127.0.0.1'"); my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets"); while (1) { @@ -23,11 +23,19 @@ while (1) { $q->execute; my %ip_to_switch = (); + my %secondary_ip_to_switch = (); while (my $ref = $q->fetchrow_hashref) { my $switch = $ref->{'switch'}; + my $ip = $ref->{'ip'}; $ping->host_add($ip); $ip_to_switch{$ip} = $switch; + + my $secondary_ip = $ref->{'secondary_ip'}; + if (defined($secondary_ip)) { + $ping->host_add($secondary_ip); + $secondary_ip_to_switch{$secondary_ip} = $switch; + } } my $result = $ping->ping(); die $ping->get_error if (!defined($result)); @@ -35,13 +43,23 @@ while (1) { $dbh->do('COPY ping (switch, latency_ms) FROM STDIN'); # date is implicitly now. while (my ($ip, $latency) = each %$result) { my $switch = $ip_to_switch{$ip}; - if (!defined($latency)) { - $dbh->pg_putcopydata("$switch\t\\N\n"); - } else { - $dbh->pg_putcopydata("$switch\t$latency\n"); - } + next if (!defined($switch)); + + $latency //= "\\N"; + $dbh->pg_putcopydata("$switch\t$latency\n"); } $dbh->pg_putcopyend(); + + $dbh->do('COPY ping_secondary_ip (switch, latency_ms) FROM STDIN'); # date is implicitly now. + while (my ($ip, $latency) = each %$result) { + my $switch = $secondary_ip_to_switch{$ip}; + next if (!defined($switch)); + + $latency //= "\\N"; + $dbh->pg_putcopydata("$switch\t$latency\n"); + } + $dbh->pg_putcopyend(); + $dbh->commit; # ping linknets diff --git a/clients/update-public-nms.sh b/clients/update-public-nms.sh index ed1807c..535d02d 100755 --- a/clients/update-public-nms.sh +++ b/clients/update-public-nms.sh @@ -1,12 +1,12 @@ #!/bin/sh -DIR=/srv/www/nms-public.tg13.gathering.org +DIR=/root/tgmanage/web/nms-public.gathering.org -wget -qO$DIR/nettkart-trafikk.png.new http://nms.tg13.gathering.org/nettkart.pl -wget -qO$DIR/nettkart-dhcp.png.new http://nms.tg13.gathering.org/dhcpkart.pl -wget -qO$DIR/led.txt.new http://nms.tg13.gathering.org/led.pl +wget -qO$DIR/nettkart-trafikk.png.new http://nms.tg14.gathering.org/nettkart.pl +wget -qO$DIR/nettkart-dhcp.png.new http://nms.tg14.gathering.org/dhcpkart.pl +wget -qO$DIR/led.txt.new http://nms.tg14.gathering.org/led.pl mv $DIR/nettkart-trafikk.png.new $DIR/nettkart-trafikk.png mv $DIR/nettkart-dhcp.png.new $DIR/nettkart-dhcp.png mv $DIR/led.txt.new $DIR/led.txt -/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' /srv/www/nms-public.tg13.gathering.org/dhcp.html -/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' /srv/www/nms-public.tg13.gathering.org/trafikk.html +/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' $DIR/dhcp.html +/usr/bin/perl -i -pe 'use POSIX qw(strftime); my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())); s/Sist oppdatert:.*/Sist oppdatert: $timestamp/g;' $DIR/trafikk.html diff --git a/netlist.txt b/netlist.txt index 54150fa..bda3bc9 100644 --- a/netlist.txt +++ b/netlist.txt @@ -6,6 +6,8 @@ 151.216.226.0 24 presse 151.216.227.0 25 fugleberget1 151.216.227.128 25 fugleberget2 +151.216.228.0 26 kompett +151.216.228.64 26 kompott 151.216.229.0 24 gayme 151.216.230.0 24 info-dask 151.216.232.0 25 resepsjon @@ -24,6 +26,7 @@ 151.216.245.128 27 apenett00 151.216.245.160 27 apenett06 151.216.245.192 27 apekatt +151.216.250.0 24 bordell 151.216.252.0 24 noc 151.216.253.0 24 noc-server 151.216.254.0 24 tele diff --git a/sql/nms.sql b/sql/nms.sql index 47aacdb..6af4e2a 100644 --- a/sql/nms.sql +++ b/sql/nms.sql @@ -594,6 +594,10 @@ create table ping ( switch integer not null, updated timestamptz not null defaul create index updated_index on ping ( updated ); alter table public.ping owner to nms; +create table ping_secondary_ip ( switch integer not null, updated timestamptz not null default current_timestamp, latency_ms float ); +create index updated_index3 on ping_secondary_ip ( updated ); +alter table public.ping_secondary_ip owner to nms; + create table linknets ( linknet serial not null, switch1 integer not null, addr1 inet not null, switch2 integer not null, addr2 inet not null ); alter table public.linknets owner to nms; diff --git a/web/nms-public.gathering.org/dhcp.html b/web/nms-public.gathering.org/dhcp.html deleted file mode 100644 index 332ea0a..0000000 --- a/web/nms-public.gathering.org/dhcp.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>NMS Public - DHCP KART - The Gathering 2013</title> -<meta http-equiv="refresh" content="5;URL='/dhcp.html'"> -</head> -<body> -<img src="nettkart-dhcp.png" alt="DHCP KART" /> -<p>Sist oppdatert: Sun, 31 Mar 2013 16:03:02 +0200 -</body> -</html> diff --git a/web/nms-public.gathering.org/index.html b/web/nms-public.gathering.org/index.html deleted file mode 100644 index 1917fd3..0000000 --- a/web/nms-public.gathering.org/index.html +++ /dev/null @@ -1,15 +0,0 @@ -<html> -<head> -<title>NMS Public - The Gathering 2013</title> -</head> - -<body> - -<h1>NMS Public - The Gathering 2013</h1> - -<h2><a href="dhcp.html">DHCP-kart</a></h2> -<h2><a href="trafikk.html">Trafikk-kart</a></h2> - -</body> -</html> - diff --git a/web/nms-public.gathering.org/led.txt b/web/nms-public.gathering.org/led.txt deleted file mode 100644 index 42a189c..0000000 --- a/web/nms-public.gathering.org/led.txt +++ /dev/null @@ -1,256 +0,0 @@ -e65-4 off -ap-e47-2 off -ap-e15-1 off -e11-4 off -e69-1 off -ap-e13-4 off -ap-e11-3 off -e23-2 off -e41-2 off -e65-1 off -ap-e25-1 off -e21-3 off -e3-3 off -e45-1 off -ap-e59-4 off -ap-e17-3 off -ap-e69-3 off -e45-2 off -e25-2 off -ap-e61-3 off -e55-1 off -ap-e49-2 off -e5-3 off -ap-e59-2 off -e15-3 off -ap-e49-1 off -e67-4 off -e21-1 off -ap-e13-3 off -ap-e59-1 off -e27-1 off -ap-e43-4 off -ap-e37-1 off -e7-3 off -ap-e77-1 off -ap-e43-3 off -ap-e65-4 off -ap-e23-2 off -ap-e5-4 off -e1-3 off -e63-4 off -ap-e19-3 off -ap-e39-1 off -e53-2 off -e13-1 off -ap-e13-1 off -ap-e63-1 off -ap-e55-3 off -e65-2 off -ap-e73-2 off -ap-e71-4 off -ap-e77-2 off -ap-e63-4 off -e25-3 off -ap-e49-4 off -ap-e43-1 off -e63-2 off -e19-2 off -e61-4 off -ap-e53-4 off -e55-4 off -ap-e69-4 off -ap-e41-2 off -e9-4 off -e43-4 off -ap-e47-4 off -ap-e15-4 off -ap-e17-1 off -ap-e19-4 off -ap-e37-2 off -ap-e67-1 off -e19-1 off -ap-e23-1 off -ap-e29-2 off -e49-4 off -ap-e7-3 off -ap-e65-3 off -e13-3 off -e57-3 off -ap-e25-3 off -e23-3 off -e37-2 off -ap-e1-3 off -ap-e75-2 off -e47-4 off -e21-4 off -e33-1 off -ap-e69-2 off -ap-e17-2 off -ap-e73-3 off -ap-e71-3 off -ap-e25-4 off -ap-e45-3 off -e69-2 off -e13-2 off -e51-1 off -ap-e7-4 off -ap-e9-3 off -e19-4 off -e17-4 off -e61-2 off -e57-2 off -ap-e63-3 off -ap-e45-2 off -e67-1 off -ap-e27-1 off -e51-2 off -e49-2 off -ap-e19-1 off -ap-e47-1 off -e59-3 off -ap-e25-2 off -ap-e65-2 off -e21-2 off -e59-4 off -e39-2 off -ap-e3-4 off -e19-3 off -ap-e29-1 off -e13-4 off -ap-e35-1 off -ap-e75-3 off -e35-1 off -ap-e13-2 off -ap-e57-3 off -ap-e73-4 off -e71-2 off -ap-e71-1 off -ap-e75-1 off -e71-1 off -ap-e41-1 off -ap-e57-4 off -e23-1 off -e77-1 off -e69-3 off -e29-1 off -ap-e49-3 off -ap-e45-1 off -e59-1 off -e73-3 off -e53-1 off -ap-e33-2 off -ap-e47-3 off -e17-1 off -e31-1 off -e55-3 off -e17-3 off -ap-e19-2 off -ap-e61-1 off -ap-e63-2 off -ap-e21-3 off -e75-1 off -ap-e61-2 off -ap-e55-1 off -ap-e33-1 off -e53-4 off -e3-4 off -ap-e9-4 off -ap-e31-1 off -e65-3 off -e75-4 off -ap-e15-2 off -ap-e35-2 off -e51-4 off -ap-e55-4 off -e51-3 off -ap-e21-1 off -e39-1 off -e63-1 off -ap-e57-1 off -ap-e11-1 off -e43-2 off -e75-3 off -e47-1 off -e25-4 off -e71-4 off -e47-2 off -e43-3 off -ap-e15-3 off -ap-e3-3 off -ap-e75-4 off -ap-e43-2 off -e15-2 off -ap-e67-3 off -ap-e59-3 off -e27-2 off -e11-1 off -ap-e23-3 off -ap-e11-2 off -ap-e51-2 off -e55-2 off -ap-e27-2 off -ap-e53-2 off -ap-e11-4 off -e69-4 off -e33-2 off -ap-e57-2 off -e11-3 off -e57-1 off -e37-1 off -e11-2 off -e53-3 off -e67-2 off -ap-e53-3 off -e67-3 off -ap-e71-2 off -e57-4 off -e73-4 off -e73-1 off -ap-e67-2 off -e61-3 off -e29-2 off -ap-e67-4 off -e15-1 off -ap-e53-1 off -ap-e55-2 off -ap-e5-3 off -ap-e51-1 off -ap-e61-4 off -ap-e45-4 off -e35-2 off -e61-1 off -e49-1 off -e43-1 off -ap-e69-1 off -ap-e39-2 off -e45-3 off -e23-4 off -e73-2 off -ap-e23-4 off -ap-e31-2 off -e71-3 off -e15-4 off -e17-2 off -e45-4 off -e47-3 off -ap-e73-1 off -e49-3 off -e63-3 off -ap-e21-2 off -ap-e51-4 off -e7-4 off -e41-1 off -ap-e17-4 off -e1-4 off -e5-4 off -ap-e1-4 off -e59-2 off -ap-e51-3 off -ap-e21-4 off -e25-1 off -e75-2 off -e77-2 off -e31-2 off -e9-3 off -ap-e65-1 off diff --git a/web/nms-public.gathering.org/nettkart-dhcp.png b/web/nms-public.gathering.org/nettkart-dhcp.png Binary files differdeleted file mode 100644 index d9232de..0000000 --- a/web/nms-public.gathering.org/nettkart-dhcp.png +++ /dev/null diff --git a/web/nms-public.gathering.org/nettkart-trafikk.png b/web/nms-public.gathering.org/nettkart-trafikk.png Binary files differdeleted file mode 100644 index 79661fc..0000000 --- a/web/nms-public.gathering.org/nettkart-trafikk.png +++ /dev/null diff --git a/web/nms-public.gathering.org/trafikk.html b/web/nms-public.gathering.org/trafikk.html deleted file mode 100644 index ee417a8..0000000 --- a/web/nms-public.gathering.org/trafikk.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>NMS Public - TRAFIKK KART - The Gathering 2013</title> -<meta http-equiv="refresh" content="60;URL='/trafikk.html'"> -</head> -<body> -<img src="nettkart-trafikk.png" alt="TRAFIKK KART" /> -<p>Sist oppdatert: Sun, 31 Mar 2013 16:03:02 +0200 -</body> -</html> diff --git a/web/nms.gathering.org/ping-json.pl b/web/nms.gathering.org/ping-json.pl index 78e795a..e661e8f 100755 --- a/web/nms.gathering.org/ping-json.pl +++ b/web/nms.gathering.org/ping-json.pl @@ -7,13 +7,18 @@ use nms; my $cgi = CGI->new; my $dbh = nms::db_connect(); +my %json = (); my $q = $dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping WHERE updated >= NOW() - INTERVAL '15 secs' ORDER BY switch, updated DESC;"); $q->execute(); - -my %json = (); while (my $ref = $q->fetchrow_hashref()) { - $json{'switches'}{$ref->{'switch'}} = $ref->{'latency_ms'}; + $json{'switches'}{$ref->{'switch'}}{'latency'} = $ref->{'latency_ms'}; +} + +my $qs = $dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping_secondary_ip WHERE updated >= NOW() - INTERVAL '15 secs' ORDER BY switch, updated DESC;"); +$qs->execute(); +while (my $ref = $qs->fetchrow_hashref()) { + $json{'switches'}{$ref->{'switch'}}{'latency_secondary'} = $ref->{'latency_ms'}; } my $lq = $dbh->prepare("SELECT DISTINCT ON (linknet) linknet, latency1_ms, latency2_ms FROM linknet_ping WHERE updated >= NOW() - INTERVAL '15 secs' ORDER BY linknet, updated DESC;"); diff --git a/web/nms.gathering.org/ping.js b/web/nms.gathering.org/ping.js index c1b2fbe..ce3d99f 100644 --- a/web/nms.gathering.org/ping.js +++ b/web/nms.gathering.org/ping.js @@ -110,6 +110,15 @@ function update_ping(json) { setTimeout(get_ping, 1000); } +function gradient_from_latency(latency_ms, latency_secondary_ms) { + if (latency_secondary_ms === undefined) { + return rgb_from_latency(latency_ms); + } + return '-webkit-gradient(linear, left top, left bottom, ' + + 'from(' + rgb_from_latency(latency_ms) + '), ' + + 'to(' + rgb_from_latency(latency_secondary_ms) + '))'; +} + function rgb_from_latency(latency_ms) { if (latency_ms === null || latency_ms === undefined) { return '#0000ff'; @@ -127,8 +136,14 @@ function rgb_from_latency(latency_ms) { function really_update_ping(json) { if (json['switches']) { for (var switchnum in switches) { - switches[switchnum].style.backgroundColor = rgb_from_latency(json['switches'][switchnum]); - } + if (json['switches'][switchnum]) { + switches[switchnum].style.background = + gradient_from_latency(json['switches'][switchnum]['latency'], + json['switches'][switchnum]['latency_secondary']); + } else { + switches[switchnum].style.background = '#0000ff'; + } + } } if (json['linknets']) { for (var linknetnum in linknets) { |