wanlinkinfo.in 1.36 KB
Newer Older
Chad Barb's avatar
 
Chad Barb committed
1 2 3 4 5 6 7 8
#!/usr/bin/perl -w

use English;
# use strict;

use lib '@prefix@/lib';
use libdb;

Chad Barb's avatar
Chad Barb committed
9
my $result = DBQueryFatal("SELECT node_id1, iface1, node_id2, iface2, time, bandwidth " .
Chad Barb's avatar
 
Chad Barb committed
10 11 12 13
			  "FROM widearea_delays");

my %nodename = ();
my %speeds   = ();
Chad Barb's avatar
Chad Barb committed
14
my %bws   = ();
Chad Barb's avatar
 
Chad Barb committed
15

Chad Barb's avatar
Chad Barb committed
16
while (my ($node_id1, $iface1, $node_id2, $iface2, $time, $bw) = $result->fetchrow) {
Chad Barb's avatar
 
Chad Barb committed
17 18 19 20 21 22 23 24 25
    my $msectime = $time * 1000;
    my $glom1    = $node_id1 . ":" . $iface1;
    my $glom2    = $node_id2 . ":" . $iface2;

    # print "Got $glom1 to $glom2 in $msectime ms\n";
    $nodename{ $glom1 } = "1";
    $nodename{ $glom2 } = "1";

    $speeds{ $glom1 . "+" . $glom2 } = $msectime;
Chad Barb's avatar
Chad Barb committed
26
    $bws{ $glom1 . "+" . $glom2 } = $bw;
Chad Barb's avatar
 
Chad Barb committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
}

print scalar( keys %nodename ) . "\n";

foreach my $i (sort (keys %nodename)) {
    print "$i\n";
}

foreach my $i (sort (keys %nodename)) {
    foreach my $j (sort (keys %nodename)) {
	my $s = "0";
	if (exists $speeds{ $i."+".$j } ) {
	    $s = $speeds{ $i . "+" . $j };
	} 
	print sprintf( "%-5i ", $s );
    }
    print "\n";
}
Chad Barb's avatar
Chad Barb committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58

foreach my $i (sort (keys %nodename)) {
    foreach my $j (sort (keys %nodename)) {
        # the following is conceptually
        # the bandwidth of a machine to itself.
	# using ttcp, a typical value was found to be 180 MB/sec
	my $s = "180000"; 
	if (exists $bws{ $i."+".$j } ) {
	    $s = $bws{ $i . "+" . $j };
	} 
	print sprintf( "%-6i ", $s );
    }
    print "\n";
}