8 my $dbh = nms::db_connect();
9 print $cgi->header(-type=>'text/html', -refresh=>'45; http://nms.tg07.gathering.org/nettkart-telnet.pl');
14 <title>nettkart - telnet</title>
20 my $q = $dbh->prepare('select * from switches natural join placements natural left join
21 ( select switch,sum(bytes_in)/count(*) as
22 bytes_in,sum(bytes_out)/count(*) as bytes_out from get_datarate() group
25 while (my $ref = $q->fetchrow_hashref()) {
26 $ref->{'placement'} =~ /\((\d+),(\d+)\),\((\d+),(\d+)\)/;
28 my $traffic = 4.0 * $ref->{'bytes_in'} + $ref->{'bytes_out'}; # average and convert to bits (should be about the same in practice)
30 if ($traffic >= 1_000_000_000) {
31 $ttext = sprintf "%.2f Gbit/port/sec", $traffic/1_000_000_000;
32 } elsif ($traffic => 1_000_000) {
33 $ttext = sprintf "%.2f Mbit/port/sec", $traffic/1_000_000;
35 $ttext = sprintf "%.2f kbit/port/sec", $traffic/1_000;
38 printf " <area shape=\"rect\" coords=\"%u,%u,%u,%u\" target=\"blank\" href=\"telnet://$ref->{'ip'}\" alt=\"%s (%s)\" onmouseover=\"window.status='%s (%s)'; return true\" onmouseout=\"window.status=''\" />\n",
39 $3, $4, $1, $2, $ref->{'switch'}, $ref->{'sysname'},
40 $ttext, $ref->{'sysname'}, $ttext;
47 <p><img src="nettkart.pl" usemap="#switches" /></p>