line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HON::EC2::Snapshots::Monitoring; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
38931
|
use 5.006; |
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
90
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
HON::EC2::Snapshots::Monitoring - Log file monitoring |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.03 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
11
|
use base 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
958
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw/findLogsOfTheDay isLogOk/; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use HON::EC2::Snapshots::Monitoring; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my @logs = findLogsOfTheDay(\@lines, '12-18-2015'); |
27
|
|
|
|
|
|
|
isLogOk(@logs); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Several utilities functions |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 findLogsOfTheDay |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Find logs of the day |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub findLogsOfTheDay { |
42
|
4
|
|
|
4
|
1
|
23869
|
my ( $refLines, $date ) = @_; |
43
|
4
|
|
|
|
|
9
|
my @logsOfTheDay = (); |
44
|
4
|
|
|
|
|
6
|
my $keepLogs = 0; |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
8
|
foreach my $line ( @{$refLines} ) { |
|
4
|
|
|
|
|
10
|
|
47
|
201
|
100
|
|
|
|
559
|
if ( $line =~ m/Starting\s\w+\sBackup\s--\s(\d{1,2}-\d{2}-\d{4})/xmsgi ) { |
48
|
12
|
100
|
|
|
|
36
|
if ( $1 eq $date ) { |
49
|
4
|
|
|
|
|
8
|
$keepLogs = 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
201
|
100
|
|
|
|
414
|
if ( $keepLogs == 1 ) { |
54
|
97
|
|
|
|
|
151
|
push @logsOfTheDay, $line; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
201
|
100
|
|
|
|
621
|
if ( $line =~ m/Backup\sdone/xmsgi ) { |
58
|
12
|
|
|
|
|
20
|
$keepLogs = 0; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
4
|
|
|
|
|
46
|
return @logsOfTheDay; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 isLogOk |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Verify specific part of the log |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub isLogOk { |
71
|
4
|
|
|
4
|
1
|
2499
|
my @lines = @_; |
72
|
4
|
|
|
|
|
7
|
my $isSnapshot = 0; |
73
|
4
|
|
|
|
|
6
|
my $isTagging = 0; |
74
|
4
|
|
|
|
|
7
|
my $isPurging = 0; |
75
|
4
|
|
|
|
|
6
|
my $isPurgeAfter = 0; |
76
|
|
|
|
|
|
|
|
77
|
4
|
|
|
|
|
9
|
foreach my $line (@lines) { |
78
|
97
|
100
|
|
|
|
225
|
if ( |
79
|
|
|
|
|
|
|
$line =~ m/^Snapshots\staken\sby\sec2-automate-backup-awscli[.]sh/xmsgi ) |
80
|
|
|
|
|
|
|
{ |
81
|
3
|
|
|
|
|
4
|
$isSnapshot = 1; |
82
|
|
|
|
|
|
|
} |
83
|
97
|
100
|
|
|
|
243
|
if ( $line =~ m/Tagging\sSnapshot\ssnap-/xmsgi ) { |
84
|
4
|
|
|
|
|
6
|
$isTagging = 1; |
85
|
|
|
|
|
|
|
} |
86
|
97
|
100
|
|
|
|
311
|
if ( $line =~ m/Snapshot\sPurging\sis/xmsgi ) { |
87
|
2
|
|
|
|
|
4
|
$isPurging = 1; |
88
|
|
|
|
|
|
|
} |
89
|
97
|
100
|
|
|
|
269
|
if ( $line =~ m/PurgeAfterFE\sdate/xmsgi ) { |
90
|
4
|
|
|
|
|
9
|
$isPurgeAfter = 1; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
4
|
|
100
|
|
|
49
|
return ( $isSnapshot and $isTagging and $isPurging and $isPurgeAfter ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
William Belle, C<< >> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
104
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
105
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SUPPORT |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
perldoc HON::EC2::Snapshots::Monitoring |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
You can also look for information at: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * CPAN Ratings |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * Search CPAN |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Copyright 2015 William Belle. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
148
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
149
|
|
|
|
|
|
|
the Free Software Foundation; version 2 dated June, 1991 or at your option |
150
|
|
|
|
|
|
|
any later version. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
153
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
154
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
155
|
|
|
|
|
|
|
GNU General Public License for more details. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
A copy of the GNU General Public License is available in the source tree; |
158
|
|
|
|
|
|
|
if not, write to the Free Software Foundation, Inc., |
159
|
|
|
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; # End of HON::EC2::Snapshots::Monitoring |