From: mitty Date: Sun, 12 Dec 2010 19:45:20 +0000 (+0000) Subject: * check status of given urls X-Git-Tag: r89-trunk~4 X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=27d65466e76c54aa31aff9152fb7227a94d4224c;p=lab.git * check status of given urls git-svn-id: https://lab.mitty.jp/svn/lab/trunk@86 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- diff --git a/misc/checkalive.pl b/misc/checkalive.pl new file mode 100644 index 0000000..a786870 --- /dev/null +++ b/misc/checkalive.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use utf8; + +use Crypt::SSLeay; +use LWP::UserAgent; +use HTTP::Request::Common; +use YAML::Tiny; +use FindBin qw($Bin); + +my $conf = YAML::Tiny->read("$Bin/checkalive.yml")->[0]; + +my $ua = LWP::UserAgent->new; + +foreach my $url (@{$conf->{urls}}) { + my $response = $ua->request(GET $url); + logging($response->status_line, " ", $url); +} + +sub logging { + my (@msg) = @_; + + my $logfile = "$Bin/checkalive." . today() . ".log"; + open LOG, ">>$logfile"; + print LOG "[" . localtime() . "] ($$) " , @msg, "\n"; + close LOG; +} + +sub today { + my ($s, $mi, $h, $d, $mo, $y, $w) = localtime(); + $mo++; $y += 1900; + return sprintf("%4d%02d%02d", $y, $mo, $d, $h, $mi, $s); +} diff --git a/misc/checkalive.yml b/misc/checkalive.yml new file mode 100644 index 0000000..12c7a61 --- /dev/null +++ b/misc/checkalive.yml @@ -0,0 +1,5 @@ +urls : + - http://www.coins.tsukuba.ac.jp/ + - https://www.coins.tsukuba.ac.jp/ + - http://www.coins.tsukuba.ac.jp/~s0711489/ + - https://www.coins.tsukuba.ac.jp/~s0711489/