trunk
Rev | Line | |
---|
[27d6546] | 1 | #!/usr/bin/perl -w |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use utf8; |
---|
| 6 | |
---|
| 7 | use Crypt::SSLeay; |
---|
| 8 | use LWP::UserAgent; |
---|
| 9 | use HTTP::Request::Common; |
---|
| 10 | use YAML::Tiny; |
---|
| 11 | use FindBin qw($Bin); |
---|
| 12 | |
---|
| 13 | my $conf = YAML::Tiny->read("$Bin/checkalive.yml")->[0]; |
---|
| 14 | |
---|
| 15 | my $ua = LWP::UserAgent->new; |
---|
| 16 | |
---|
| 17 | foreach my $url (@{$conf->{urls}}) { |
---|
| 18 | my $response = $ua->request(GET $url); |
---|
| 19 | logging($response->status_line, " ", $url); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | sub logging { |
---|
| 23 | my (@msg) = @_; |
---|
| 24 | |
---|
| 25 | my $logfile = "$Bin/checkalive." . today() . ".log"; |
---|
| 26 | open LOG, ">>$logfile"; |
---|
| 27 | print LOG "[" . localtime() . "] ($$) " , @msg, "\n"; |
---|
| 28 | close LOG; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | sub today { |
---|
| 32 | my ($s, $mi, $h, $d, $mo, $y, $w) = localtime(); |
---|
| 33 | $mo++; $y += 1900; |
---|
| 34 | return sprintf("%4d%02d%02d", $y, $mo, $d, $h, $mi, $s); |
---|
| 35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.