script/hon-ec2-snapshots-monitoring.pl untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 51 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
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 - hon-ec2-snapshots-monitoring.pl
15  
16 Monitor EC2 snapshots log
17  
18 =head1 SYNOPSIS
19  
20 hon-ec2-snapshots-monitoring.pl --help
21  
22 hon-ec2-snapshots-monitoring.pl --log=/path/to/file.log
23  
24 =head1 ARGUMENTS
25  
26 =over 2
27  
28 =item --log=/path/to/file.log
29  
30 path to the log file
31  
32 =back
33  
34 =cut
35  
36 my ( $log, $help );
37 GetOptions(
38 "log=s" => \$log,
39 "help" => \$help,
40 )
41 || pod2usage(2);
42  
43 if ( $help || !$log ) {
44 pod2usage(1);
45 exit(0);
46 }
47  
48 my $time = Time::Piece->new;
49 my @lines = io($log)->slurp;
50 my @todayLogs = findLogsOfTheDay(\@lines, $time->mdy);
51 if (isLogOk(@todayLogs)){
52 print 'exit(0)', "\n";
53 exit(0);
54 } else {
55 print 'exit(1)', "\n";
56 exit(1);
57 }