diff options
author | Knut Auvor Grythe <knut@auvor.no> | 2015-04-03 10:42:38 +0200 |
---|---|---|
committer | root <root@einstein.tg15.gathering.org> | 2015-04-03 10:42:38 +0200 |
commit | ce10416c8c398698d0917a66f022016c330a9530 (patch) | |
tree | c86d16e9511b70456e246accee5e5dabadb0511d | |
parent | f41889dafec7522293ac186ec4dbf20005a33fdb (diff) |
Make maps use new SQL schema
-rwxr-xr-x | web/nms.gathering.org/aggregated_traffic.pl | 2 | ||||
-rwxr-xr-x | web/nms.gathering.org/nettkart-json.pl | 6 | ||||
-rwxr-xr-x | web/nms.gathering.org/nettkart.pl | 8 | ||||
-rwxr-xr-x | web/nms.gathering.org/portkart.pl | 10 | ||||
-rwxr-xr-x | web/nms.gathering.org/showswitch.pl | 16 |
5 files changed, 21 insertions, 21 deletions
diff --git a/web/nms.gathering.org/aggregated_traffic.pl b/web/nms.gathering.org/aggregated_traffic.pl index 5c78e73..e2f3d97 100755 --- a/web/nms.gathering.org/aggregated_traffic.pl +++ b/web/nms.gathering.org/aggregated_traffic.pl @@ -12,7 +12,7 @@ my $cgi = CGI->new; print $cgi->header(-type=>'text/json', -expires=>'now'); -my $q = $dbh->prepare('select sum(n1.sum_in) as sum_in, sum(n1.sum_out) as sum_out from (select sum(ifInoctets) as sum_in, sum(ifOutoctets) as sum_out from polls2 where time >= now() - \'15 minutes\'::interval group by switch) as n1'); +my $q = $dbh->prepare('select sum(n1.sum_in) as sum_in, sum(n1.sum_out) as sum_out from (select sum(ifhcinoctets) as sum_in, sum(ifhcoutoctets) as sum_out from polls where time >= now() - \'15 minutes\'::interval group by switch) as n1'); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { my $bitsface = $ref->{'sum_in'}/900/8; diff --git a/web/nms.gathering.org/nettkart-json.pl b/web/nms.gathering.org/nettkart-json.pl index 36685a4..c218642 100755 --- a/web/nms.gathering.org/nettkart-json.pl +++ b/web/nms.gathering.org/nettkart-json.pl @@ -22,7 +22,7 @@ if (defined($secret2)) { my $dbh = nms::db_connect(); my %json = (); -my $q = $dbh->prepare("select * from ( SELECT switch,sysname,sum(ifinoctets) AS ifinoctets,sum(ifoutoctets) AS ifoutoctets from switches natural left join get_current_datarate() where ip <> inet '127.0.0.1' group by switch,sysname) t1 natural join placements order by zorder;"); +my $q = $dbh->prepare("select * from ( SELECT switch,sysname,sum(ifhcinoctets) AS ifhcinoctets,sum(ifhcoutoctets) AS ifhcoutoctets from switches natural left join get_current_datarate() where ip <> inet '127.0.0.1' group by switch,sysname) t1 natural join placements order by zorder;"); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { @@ -34,9 +34,9 @@ while (my $ref = $q->fetchrow_hashref()) { my $clr; - if (defined($ref->{'ifinoctets'})) { + if (defined($ref->{'ifhcinoctets'})) { my $intensity = 0.0; - my $traffic = 4.0 * ($ref->{'ifinoctets'} + $ref->{'ifoutoctets'}); # average and convert to bits (should be about the same in practice) + my $traffic = 4.0 * ($ref->{'ifhcinoctets'} + $ref->{'ifhcoutoctets'}); # average and convert to bits (should be about the same in practice) my $max = 100_000_000_000.0; # 100Gbit my $min = 10_000_000.0; # 10Mbit diff --git a/web/nms.gathering.org/nettkart.pl b/web/nms.gathering.org/nettkart.pl index 2fc0e8b..bf3bf74 100755 --- a/web/nms.gathering.org/nettkart.pl +++ b/web/nms.gathering.org/nettkart.pl @@ -56,9 +56,9 @@ $text_img->stringFT($tclr, "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", $text_img->stringFT($tclr, "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", 10, 0, 40, 47 + (236-42)*2.0/4.0, "1 Gbit/sec"); $text_img->stringFT($tclr, "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", 10, 0, 40, 47 + (236-42)*3.0/4.0, "100 Mbit/sec"); $text_img->stringFT($tclr, "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", 10, 0, 40, 47 + (236-42)*4.0/4.0, "10 Mbit/sec"); -$text_img->stringFT($tclr, "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", 10, 0, 1600, 1000, "NMS (C) 2005-2012 Tech:Server"); +$text_img->stringFT($tclr, "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", 10, 0, 1600, 1000, "NMS (C) 2005-2015 Tech:Server"); -my $q = $dbh->prepare("select * from ( SELECT switch,sysname,sum(ifinoctets) AS ifinoctets,sum(ifoutoctets) AS ifoutoctets from switches natural left join get_current_datarate() where ip <> inet '127.0.0.1' group by switch,sysname) t1 natural join placements order by zorder;"); +my $q = $dbh->prepare("select * from ( SELECT switch,sysname,sum(ifhcinoctets) AS ifhcinoctets,sum(ifhcoutoctets) AS ifhcoutoctets from switches natural left join get_current_datarate() where ip <> inet '127.0.0.1' group by switch,sysname) t1 natural join placements order by zorder;"); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { @@ -70,9 +70,9 @@ while (my $ref = $q->fetchrow_hashref()) { my $clr; - if (defined($ref->{'ifinoctets'})) { + if (defined($ref->{'ifhcinoctets'})) { my $intensity = 0.0; - my $traffic = 4.0 * ($ref->{'ifinoctets'} + $ref->{'ifoutoctets'}); # average and convert to bits (should be about the same in practice) + my $traffic = 4.0 * ($ref->{'ifhcinoctets'} + $ref->{'ifhcoutoctets'}); # average and convert to bits (should be about the same in practice) my $max = 100_000_000_000.0; # 100Gbit my $min = 10_000_000.0; # 10Mbit diff --git a/web/nms.gathering.org/portkart.pl b/web/nms.gathering.org/portkart.pl index 8bcff0b..ce7dcdd 100755 --- a/web/nms.gathering.org/portkart.pl +++ b/web/nms.gathering.org/portkart.pl @@ -37,7 +37,7 @@ sub portnum($) { return undef; } -my $q = $dbh->prepare('select switch,ifdescr,ifinoctets,ifoutoctets,placement,switchtype from switches natural join placements natural join get_datarate() where switchtype like \'%2200%\' and sysname like \'e%-%\''); +my $q = $dbh->prepare('select switch,ifname,ifhcinoctets,ifhcoutoctets,placement,switchtype from switches natural join placements natural join get_datarate() where switchtype like \'%2200%\' and sysname like \'e%-%\''); $q->execute(); while (my $ref = $q->fetchrow_hashref()) { @@ -47,9 +47,9 @@ while (my $ref = $q->fetchrow_hashref()) { my $clr; - if (defined($ref->{'ifinoctets'})) { + if (defined($ref->{'ifhcinoctets'})) { my $intensity = 0.0; - my $traffic = 4.0 * ($ref->{'ifinoctets'} + $ref->{'ifoutoctets'}); # average and convert to bits (should be about the same in practice) + my $traffic = 4.0 * ($ref->{'ifhcinoctets'} + $ref->{'ifhcoutoctets'}); # average and convert to bits (should be about the same in practice) my $max = 100_000_000_000.0; # 1Gbit my $min = 1_000_000.0; # 1Mbit @@ -64,8 +64,8 @@ while (my $ref = $q->fetchrow_hashref()) { $ref->{'placement'} =~ /\((\d+),(\d+)\),\((\d+),(\d+)\)/; my $npo = 48; - my $f = portnum($ref->{'ifdescr'}) % 2; - my $po = (portnum($ref->{'ifdescr'}) - $f)/2; + my $f = portnum($ref->{'ifname'}) % 2; + my $po = (portnum($ref->{'ifname'}) - $f)/2; my $h = 2*($2-$4)/$npo; my $w = ($1-$3)/2; diff --git a/web/nms.gathering.org/showswitch.pl b/web/nms.gathering.org/showswitch.pl index 3fcf422..e585841 100755 --- a/web/nms.gathering.org/showswitch.pl +++ b/web/nms.gathering.org/showswitch.pl @@ -43,7 +43,7 @@ print <<"EOF"; <h1>Switch $switch ($ref->{'sysname'} - $ref->{'ip'})</h1> EOF -my $q = $dbh->prepare('select ifdescr,\'Port \' || ifdescr as description,extract(epoch from time) as time,ifinoctets,ifoutoctets from switches natural join polls2 where time between now() - \'1 day\'::interval and now() and switch=? order by switch,ifdescr,time;') or die $dbh->errstr; +my $q = $dbh->prepare('select ifname,\'Port \' || ifname as description,extract(epoch from time) as time,ifhcinoctets,ifhcoutoctets from switches natural join polls where time between now() - \'1 day\'::interval and now() and switch=? order by switch,ifname,time;') or die $dbh->errstr; $q->execute($switch) or die $dbh->errstr; my (@totx, @toty1, @toty2) = (); @@ -81,13 +81,13 @@ sub cmp_ports { # None of the N first parts differed, this means the shortest one is first return scalar @a <=> scalar @b; } -sort { cmp_ports($a->{'ifdescr'}, $b->{'ifdescr'}) } @rows; +sort { cmp_ports($a->{'ifname'}, $b->{'ifname'}) } @rows; foreach my $ref (@rows) { my $time = $ref->{'time'}; - my $in = $ref->{'ifinoctets'}; - my $out = $ref->{'ifoutoctets'}; + my $in = $ref->{'ifhcinoctets'}; + my $out = $ref->{'ifhcoutoctets'}; next if ($time == $prev_time); - if ($ref->{'ifdescr'} ne $last_port) { + if ($ref->{'ifname'} ne $last_port) { if (defined $last_port) { my $filename = filename($switch, $last_port, $width, $height); @@ -120,9 +120,9 @@ foreach my $ref (@rows) { @y2 = (); ($min_y,$max_y) = (0, 10_000_000/8); $prev_time = $ref->{'time'}; - $prev_in = $ref->{'ifinoctets'}; - $prev_out = $ref->{'ifoutoctets'}; - $last_port = $ref->{'ifdescr'}; + $prev_in = $ref->{'ifhcinoctets'}; + $prev_out = $ref->{'ifhcoutoctets'}; + $last_port = $ref->{'ifname'}; $portname = $ref->{'description'}; ($if,$of,$ifv,$ofv) = (0,0,0,0); ($prev_time,$prev_in,$prev_out) = ($time,$in,$out); |