You are not logged in.
Pages: 1
I am writing a Perl utilty to check for dead mirrors in the pacman mirrorlist.
The Net::Ping module seems to be working, but due to some symantics the live servers are being labeled dead.
http://hastebin.com/torekataci.pl
(sorry for the ugly formatting, it was rushed)
Offline
What is your question? Your script appears to have larger problems than live servers being labelled as dead. For starters, on my machine it truncates the hostnames:
Use of uninitialized value $1 in string at ./test.pl line 15, <LIST> line 1.
dead mirror:
Use of uninitialized value $1 in string at ./test.pl line 15, <LIST> line 2.
dead mirror:
Use of uninitialized value $1 in string at ./test.pl line 15, <LIST> line 3.
dead mirror:
Use of uninitialized value $1 in string at ./test.pl line 15, <LIST> line 4.
dead mirror:
Use of uninitialized value $1 in string at ./test.pl line 15, <LIST> line 5.
dead mirror:
Use of uninitialized value $1 in string at ./test.pl line 15, <LIST> line 6.
dead mirror:
dead mirror: on.net/pub
dead mirror: net.au/pub
dead mirror: edu.au/pub
dead mirror: edu.au
EDIT:
Consider using Regexp::Common
use warnings;
use strict;
use Net::Ping;
use Regexp::Common qw /URI/;;
my @servers;
my $serverso = 0;
my $mirror;
my $p = Net::Ping->new();
open LIST, "/etc/pacman.d/mirrorlist" or die "Mirrorlist not found. Is pacman properly installed?";
while(<LIST>)
{
m|Server = $RE{URI}{HTTP}{-keep}|i or next;
$mirror = $3;
print "dead mirror: $mirror\n" unless $p->ping($mirror);
die;
}
close(LIST);
Last edited by fukawi2 (2013-05-13 02:20:25)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
1) Your regex is overconstrained. Not every mirror will match m'http://.*\.(.*\..*)/.*linux/' and of the ones that do, the parens will still capture the wrong thing sometimes.
2) Whether or not a server responds to ping is really a different question from whether it services HTTP requests. Some mirrors will not respond to ping, but that does not mean they are dead. Similarly, some servers might respond to being pinged, but that doesn't mean they host Arch mirrors. You need to change your methodology to test the thing you're actually curious about (by downloading the directory list or something).
Offline
Pages: 1