| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Getopt::Long; | ||
| 7 | use Pod::Usage; | ||
| 8 | |||
| 9 | use IO::All -utf8; | ||
| 10 | use Time::Piece; | ||
| 11 | |||
| 12 | use HON::EC2::Snapshots::Monitoring qw/findLogsOfTheDay isLogOk/; | ||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | hon-ec2-snapshots-monitoring.pl - Monitor EC2 snapshots log | ||
| 17 | |||
| 18 | =head1 VERSION | ||
| 19 | |||
| 20 | Version 0.03 | ||
| 21 | |||
| 22 | =head1 USAGE | ||
| 23 | |||
| 24 | hon-ec2-snapshots-monitoring.pl --help | ||
| 25 | |||
| 26 | hon-ec2-snapshots-monitoring.pl --log=/path/to/file.log | ||
| 27 | |||
| 28 | =head1 REQUIRED ARGUMENTS | ||
| 29 | |||
| 30 | =over 2 | ||
| 31 | |||
| 32 | =item --log=/path/to/file.log | ||
| 33 | |||
| 34 | path to the log file | ||
| 35 | |||
| 36 | =back | ||
| 37 | |||
| 38 | =head1 DESCRIPTION | ||
| 39 | |||
| 40 | Monitor EC2 snapshots log | ||
| 41 | |||
| 42 | =cut | ||
| 43 | |||
| 44 | our $VERSION = '0.03'; | ||
| 45 | |||
| 46 | my ( $log, $help ); | ||
| 47 | GetOptions( | ||
| 48 | 'log=s' => \$log, | ||
| 49 | 'help' => \$help, | ||
| 50 | ) || pod2usage(2); | ||
| 51 | |||
| 52 | if ( $help || !$log ) { | ||
| 53 | pod2usage(1); | ||
| 54 | exit 0; | ||
| 55 | } | ||
| 56 | |||
| 57 | my $time = Time::Piece->new; | ||
| 58 | my @lines = io($log)->slurp; | ||
| 59 | my @todayLogs = findLogsOfTheDay( \@lines, $time->mdy ); | ||
| 60 | if ( isLogOk(@todayLogs) ) { | ||
| 61 | print 'exit 0', "\n"; | ||
| 62 | exit 0; | ||
| 63 | } | ||
| 64 | else { | ||
| 65 | print 'exit 1', "\n"; | ||
| 66 | exit 1; | ||
| 67 | } | ||
| 68 | |||
| 69 | =head1 AUTHOR | ||
| 70 | |||
| 71 | William Belle, C<< <william.belle at gmail.com> >> | ||
| 72 | |||
| 73 | =head1 BUGS AND LIMITATIONS | ||
| 74 | |||
| 75 | Please report any bugs or feature requests to C<bug-hon-ec2-snapshots-monitoring at rt.cpan.org>, or through | ||
| 76 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HON-EC2-Snapshots-Monitoring>. I will be notified, and then you'll | ||
| 77 | automatically be notified of progress on your bug as I make changes. | ||
| 78 | |||
| 79 | =head1 LICENSE AND COPYRIGHT | ||
| 80 | |||
| 81 | Copyright 2015 William Belle. | ||
| 82 | |||
| 83 | This program is free software; you can redistribute it and/or modify | ||
| 84 | it under the terms of the GNU General Public License as published by | ||
| 85 | the Free Software Foundation; version 2 dated June, 1991 or at your option | ||
| 86 | any later version. | ||
| 87 | |||
| 88 | This program is distributed in the hope that it will be useful, | ||
| 89 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 90 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 91 | GNU General Public License for more details. | ||
| 92 | |||
| 93 | A copy of the GNU General Public License is available in the source tree; | ||
| 94 | if not, write to the Free Software Foundation, Inc., | ||
| 95 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 96 | |||
| 97 | |||
| 98 | =cut |