source: lab.git/misc/checkalive.pl @ 6f31bfb

Last change on this file since 6f31bfb was 79343a4, checked in by mitty <mitty@…>, 14 years ago
  • add executable

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@87 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

  • Property mode set to 100755
File size: 733 bytes
Line 
1#!/usr/bin/perl -w
2
3use strict;
4use warnings;
5use utf8;
6
7use Crypt::SSLeay;
8use LWP::UserAgent;
9use HTTP::Request::Common;
10use YAML::Tiny;
11use FindBin qw($Bin);
12
13my $conf = YAML::Tiny->read("$Bin/checkalive.yml")->[0];
14
15my $ua = LWP::UserAgent->new;
16
17foreach my $url (@{$conf->{urls}}) {
18    my $response = $ua->request(GET $url);
19    logging($response->status_line, " ", $url);
20}
21
22sub 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
31sub 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.