line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MMM::Report::Mail; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2335
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
4
|
1
|
|
|
1
|
|
7
|
use base qw(MMM::Report); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
291
|
|
5
|
1
|
|
|
1
|
|
1176
|
use Mail::Send; |
|
1
|
|
|
|
|
6730
|
|
|
1
|
|
|
|
|
1129
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MMM::Report::Console |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use MMM::Report::Console; |
14
|
|
|
|
|
|
|
my $mmm = MMM::Report::Console->new( configfile => $file ); |
15
|
|
|
|
|
|
|
$mmm->run(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Produce textual report of MMM work done. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SEE ALSO |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
L |
24
|
|
|
|
|
|
|
L |
25
|
|
|
|
|
|
|
L |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub body_queue { |
30
|
0
|
|
|
0
|
1
|
|
my ($self, $queue, %info) = @_; |
31
|
0
|
0
|
|
|
|
|
my $fh = $self->_get_mail_send() or return; |
32
|
0
|
0
|
|
|
|
|
%info = $queue->state_info() if (!keys %info); |
33
|
0
|
|
|
|
|
|
print $fh sprintf("%s (%s)\n", $queue->name, $queue->dest); |
34
|
0
|
0
|
|
|
|
|
print $fh sprintf(" last %s end %s\n", |
|
|
0
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$info{job}{success} ? 'mirror' : 'try', |
36
|
|
|
|
|
|
|
$info{job}{end} ? scalar (gmtime($info{job}{end})) : '(N/A)', |
37
|
|
|
|
|
|
|
); |
38
|
0
|
0
|
0
|
|
|
|
if (!$info{job}{success} && $info{success}{end}) { |
39
|
0
|
|
|
|
|
|
print $fh sprintf(" last mirror succefully done %s\n", scalar (gmtime($info{success}{end}))); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
print $fh "\n"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub run { |
45
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
46
|
0
|
|
|
|
|
|
MMM::Report::run($self); |
47
|
0
|
|
|
|
|
|
$self->_send_mail(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _get_mail_send { |
51
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
52
|
0
|
|
0
|
|
|
|
$self->{mailsend} ||= Mail::Send->new( |
|
|
|
0
|
|
|
|
|
53
|
|
|
|
|
|
|
To => $self->configval( 'default', 'mailto' ) || $ENV{USER}, |
54
|
|
|
|
|
|
|
Subject => 'MMM Report from ' . $self->hostname |
55
|
|
|
|
|
|
|
); |
56
|
0
|
|
0
|
|
|
|
$self->{fh} ||= $self->{mailsend}->open; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _send_mail { |
60
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
61
|
0
|
0
|
|
|
|
|
my $fh = $self->{fh} or return; |
62
|
0
|
|
|
|
|
|
print $fh sprintf("\n-- \nMMM :: %s\n", $MMM::VERSION); |
63
|
0
|
|
|
|
|
|
$fh->close; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Olivier Thauvin |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Copyright (C) 2006 Olivier Thauvin |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
77
|
|
|
|
|
|
|
modify it under the terms of the GNU General Public License |
78
|
|
|
|
|
|
|
as published by the Free Software Foundation; either version 2 |
79
|
|
|
|
|
|
|
of the License, or (at your option) any later version. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
82
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
83
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84
|
|
|
|
|
|
|
GNU General Public License for more details. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
87
|
|
|
|
|
|
|
along with this program; if not, write to the Free Software |
88
|
|
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|