* check status of given urls
authormitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sun, 12 Dec 2010 19:45:20 +0000 (19:45 +0000)
committermitty <mitty@7d2118f6-f56c-43e7-95a2-4bb3031d96e7>
Sun, 12 Dec 2010 19:45:20 +0000 (19:45 +0000)
git-svn-id: https://lab.mitty.jp/svn/lab/trunk@86 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

misc/checkalive.pl [new file with mode: 0644]
misc/checkalive.yml [new file with mode: 0644]

diff --git a/misc/checkalive.pl b/misc/checkalive.pl
new file mode 100644 (file)
index 0000000..a786870
--- /dev/null
@@ -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 (file)
index 0000000..12c7a61
--- /dev/null
@@ -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/