#!/usr/bin/perl # send blog update ping # Copyright(c) 2007 yamap (yamap@browncat.org) # # 2007/7/19 version 0.01 # 2007/7/20 version 0.03 use XMLRPC::Lite; my $logfile = ""; my @pingservers = ( 'http://ping.feedburner.com', 'http://ping.feedburner.jp', 'http://pingoo.jp/ping/', ); my $blogurl = "http:///"; my $waittime_first = 15; my $waittime_other = 3; @param = ("weblogUpdates", $blogurl, $blogurl); weblogUpdates->send_pings(@param); exit(); package weblogUpdates; use POSIX qw(strftime); sub result { $result->{message} = "network error"; $result->{flerror} = -1; return $result; } sub send_pings { my $wait = $waittime_first; shift(@_); my $blogname = $_[0]; open(FD, ">>$logfile"); flock(FD, LOCK_EX); print FD $now_string, " ping from $blogname start(",join(":",@_),")\n"; print $now_string, " ping from $blogname start(",join(":",@_),")\n"; my $succ = 0; my $total = 0; $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; foreach $p (@pingservers) { my $result = XMLRPC::Lite -> on_fault( sub { return "weblogUpdates"; } ) -> proxy($p) -> call('weblogUpdates.ping', @_) -> result; print FD $now_string, " : ",$p," res=",qq/$result->{message}($result->{flerror})\n/; print $now_string, " : ",$p," res=",qq/$result->{message}($result->{flerror})\n/; $succ++ if ($result != undef && $result->{flerror} == 0); $total++; sleep($wait); $wait = $waittime_other; } close FD; print "ping status = $succ/$total\n"; }