#!/usr/bin/perl
#
# Copyright (c) 2006 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see .
#
# }}}
#
#
# Show latency and/or BW samples between a pair of sites based on indices.
#
#
my $NLIST = "/usr/testbed/bin/node_list";
my $pprefix = "planet-";
# XXX Need to configure this stuff!
use lib '/usr/testbed/lib';
use libtbdb;
use Socket;
use Getopt::Std;
use Class::Struct;
use libxmlrpc;
use strict;
my $starttime = 0;
my $dolatency = 0;
my $dobw = 0;
my $doloss = 0;
my $bidir = 0;
my $number = 0;
my $usenames = 0;
my $PWDFILE = "/usr/testbed/etc/pelabdb.pwd";
my $DBNAME = "pelab";
my $DBUSER = "pelab";
my $pid;
my $eid;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
my %options = ();
if (! getopts("BNbdle:S:n:", \%options)) {
usage();
}
if (defined($options{"e"})) {
($pid,$eid) = split('/', $options{"e"});
}
if (defined($options{"B"})) {
$bidir = 1;
}
if (defined($options{"N"})) {
$usenames = 1;
}
if (defined($options{"d"})) {
$dolatency = 1;
}
if (defined($options{"b"})) {
$dobw = 1;
}
if (defined($options{"l"})) {
$doloss = 1;
}
if (defined($options{"n"})) {
$number = $options{"n"};
}
if (defined($options{"S"})) {
my $high = time();
my $low = $high - (23 * 60 * 60); # XXX
$starttime = $options{"S"};
if ($starttime && ($starttime < $low || $starttime > $high)) {
die("Bogus timestamp $starttime, should be in [$low - $high]\n");
}
}
if (!defined($pid) && @ARGV != 2) {
print STDERR "usage: showsamples.pl [-BNbdl] |all |all\n";
print STDERR " show database records for given site indices\n";
print STDERR " -B show both srcix -> dstix and dstix -> srcix\n";
print STDERR " -N two args are names rather than indicies\n";
print STDERR " -b show bandwidth\n";
print STDERR " -d show delay (the default)\n";
print STDERR " -l show loss\n";
print STDERR " -n show only the last records\n";
print STDERR " -S