source: lab/trunk/misc/checkalive.pl @ 126

Last change on this file since 126 was 87, checked in by mitty, 13 years ago
  • add executable
  • Property svn:executable set to *
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.