Measure Debian mirror responsiveness (Was: possible new official mirror in the US)
Vincent> Alternative solution: Someone writes a "dping", similar to Quake
Vincent> server browsers but that would display the list of debian mirrors
Vincent> sites sorted by responsiveness. _(;
Joey> Done. It's currenty in the chris-cust package, and will soon move
Joey> into the mirror package.
Yep. Joey brought this to my attention, and forwarded me Chris Lameter's
checkmirr script. I have polished it a little, mostly by rewriting it in
perl. In the process, I got rid from a dependency on ncftp (Chris) or wget
(Joey) so that it can be a part of the mirror package without requiring
another Depends:.
I'll probably edit it a little more, write a manual package and then add it
to the mirror package. Anyway, as it's so small, I include a working version.
Alas, I am not sure show valid this really is --- a ping snapshot is not a
good estimator of what effective throughput really is. But then, what is ?
Comments welcome, Dirk
#!/usr/bin/perl
#
# debian-mirrors measure ping time to all mirrors in README.mirrors
#
# downloads README.mirrors from ftp.debian.org (but not if a local file is
# pointed to), runs fping on all Debian mirrors, sorts the result by ping
# time and output the 'n' (default is 20) fastest
#
# Written by Dirk Eddelbuettel <edd@debian.org> and released under the GPL
# $Id: debian-mirrors.pl,v 1.2 1998/02/05 03:47:28 edd Exp $
## Yes, Net::FTP is much cooler, but we don't want to depend on libnet-perl
## 'ftp.pl' is provided by the mirror package
unshift( @INC, "/usr/lib/mirror" );
require 'ftp.pl';
#use strict; # doesn't work with ftp.pl
use English;
use File::Basename;
use vars qw($opt_h $opt_f $opt_v);
use Getopt::Std;
use IPC::Open2;
my $tempfile = "/tmp/".$file."-".$$;
my $readfrom = $tempfile;
my $max = 20;
$PROGRAM_NAME =~ s|.*/||; # strip everything before last slash
getopts('hf:n:v') or die("Try `$PROGRAM_NAME -h` for help screen.\n");
if ($opt_h or $#ARGV != -1) {
print "Usage:\n $PROGRAM_NAME [options]\n";
print "Options:\n";
print " -f file\tpoint to local version README.mirrors\n";
print " -n max\tmaximum number of mirrors to show\n";
print " -v\t\tverbose operation\n";
print " -h\t\tshow this help\n";
exit 0;
}
$max = $opt_n if ($opt_n);
if ( ! $opt_f ) {
my $hostname = "ftp.debian.org";
my $account = "ftp";
my $password = "user\@debian.org";
my $directory = "/pub/debian";
my $filename = "README.mirrors";
print "Retrieving ", $filename, " for analysis.";
ftp::debug(1) if $opt_v; # for debugging output
ftp::open($hostname,21,0,1) or die "No ftp connection\n";
ftp::login($account, $password) or die "Couldn't login\n";
ftp::cwd($directory) or die "Cannot cd to $directory\n";
ftp::get($filename, $tempfile, 0) or die "Could not get $file\n";
ftp::quit();
} else {
die "File $opt_f does not exist." unless -f $opt_f;
$readfrom = $opt_f;
}
print "Measuring ping times to all Debian mirror sites.\n" if $opt_v;
print "Please be patient.\n" if $opt_v;
my ($mirror,$path,$time);
open(DATA, $readfrom) or die "Cannot open $filename\n";
open2("PINGOUT", "PINGIN", "fping -ae") or die "Cannot start fping(1)\n";;
while (<DATA>) {
if (($mirror,$path) = ($ARG =~ m|^\s*(\S*\.\S*\.\S*.*):(/\S*)\s.*|)) {
print "Pinging $mirror \n" if $opt_v;
print PINGIN "$mirror\n"; # if ($mirror =~ m/.*\.edu$/);
}
}
close(DATA);
close(PINGIN);
open2("SORTOUT", "SORTIN", "sort -n") or die "Cannot start sort(1)\n";
while (<PINGOUT>) {
($mirror,$time) = ($ARG =~ m|^(\S*)\s*\((\d*) msec\)|);
print "fping reports $time for $mirror\n" if $opt_v;
print SORTIN "$time $mirror\n";
}
close(SORTIN);
close(PINGOUT);
my $i=0;
while (<SORTOUT>) {
print "$_" if ($i++ < $max);
}
close(SORTOUT);
--
edd@rosebud.ml.org According to the latest official figures,
http://rosebud.ml.org/~edd 43% of all statistics are totally worthless.
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: