3 use DateTime::Format::DateParse;
6 use Parse::CPAN::MirroredBy;
8 use File::Temp qw(tempdir);
11 GetOptions(\%Opt, "all|a!") or die;
13 my $ua = LWP::UserAgent->new( timeout => 12 );
14 my $rsync = File::Rsync->new({ verbose => 1, timeout => 12 });
18 "http://cpan.cpantesters.org/", # barbie
19 "rsync://cpan.cpantesters.org/cpan/", # barbie
20 "http://cpan.solfo.com/", # abh
21 "http://theoryx5.uwinnipeg.ca/pub/CPAN/", # rkobes
22 "http://cpan.hexten.net/", # andya
23 "rsync://cpan.hexten.net/cpan/", # andya
24 "http://cpan.perl.pt/", # melo
25 "http://cpan.dagolden.com/", # dagolden
26 "ftp://ftp.funet.fi/pub/languages/perl/CPAN/",
30 my $pcm = Parse::CPAN::MirroredBy->new;
31 my @mirrors = $pcm->parse_file( '/home/k/sources/CPAN/ghub/cpanpm/MIRRORED.BY' );
32 my $preferproto = "rsync";
33 for my $mirror (@mirrors) {
35 # warn "mirror[$mirror]";
36 if ($mirror->{dst_rsync} && $mirror->{dst_http}) {
37 my $uri = $mirror->{"dst_$preferproto"};
39 if ($preferproto eq "rsync") {
40 $uri =~ s|^(rsync://)?|rsync://|;
48 my $tmpdir = tempdir(CLEANUP => 1);
50 printf "%7s %-28s %s\n", "secs", "content of 02STAMP", "URL";
51 printf "%7s %-28s %s\n", "-------", "--------------------------", "----";
52 URI: for my $uri (@uri) {
54 if ($uri =~ m|^rsync://|) {
55 unless ($rsync->exec( { src => $uri . "authors/02STAMP", dest => "$tmpdir/02STAMP" } )) {
56 warn sprintf " rsync to '%s' failed: '%s'\n", $uri, $rsync->err;
59 $content = do { open my $fh, "$tmpdir/02STAMP" or die; local $/; <$fh> };
60 } elsif ($uri =~ m!^(?:http|ftp)://!) {
61 my $resp = $ua->get($uri . "authors/02STAMP");
62 if ($resp->is_success) {
63 $content = $resp->content;
65 warn sprintf " Could not reach '%s': %s\n", $uri, $resp->message;
69 die "Illegal protocol in '$uri'";
72 my $dt = DateTime::Format::DateParse->parse_datetime( $content );
73 my $now = DateTime->now;
74 my $diff = $now->epoch - $dt->epoch;
75 printf "%7d %s %s\n", $diff, $content, $uri;
78 print q{Maybe try on PAUSE
79 perl -MYAML::Syck -nle '/\(([a-z]\w+)\)/ && $S{$1}++; END { print YAML::Syck::Dump \%S }' /var/log/rsyncd2