line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MMM::Batch; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1939
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw(MMM); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
93
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw(MMM::Report::Mail); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
527
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
MMM::Batch |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use MMM::Batch; |
16
|
|
|
|
|
|
|
my $mmm = MMM::Batch->new() or die "Cannot find MMM installation"; |
17
|
|
|
|
|
|
|
$mmm->run(); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
A daemon for mmm system |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
0
|
|
|
0
|
1
|
|
my ($class, @args) = @_; |
27
|
0
|
0
|
|
|
|
|
my $mmm = $class->SUPER::new(@args) or return; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if (!$mmm->{nofork}) { |
30
|
0
|
|
|
|
|
|
Sys::Syslog::openlog('mmm', 'pid', $mmm->configval('default', 'syslog_facilities', 'daemon')); |
31
|
0
|
|
|
|
|
|
$mmm->{use_syslog} = 1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$mmm |
35
|
0
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub run { |
38
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self->load(); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my @started_tasks = (); |
43
|
0
|
|
|
|
|
|
foreach my $q ($self->get_tasks_by_name($self->list_tasks)) { |
44
|
0
|
0
|
|
|
|
|
$q->is_disable() and next; |
45
|
0
|
0
|
|
|
|
|
$q->frequency or next; |
46
|
0
|
0
|
|
|
|
|
$q->next_run_time <= scalar(time) or next; |
47
|
0
|
|
|
|
|
|
push(@started_tasks, $q->name); |
48
|
0
|
|
|
|
|
|
$self->_run_fork($q); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if (@started_tasks) { |
52
|
0
|
|
|
|
|
|
$self->log('DEBUG', 'Started tasks: %s', join(', ', @started_tasks)); |
53
|
|
|
|
|
|
|
} else { |
54
|
0
|
|
|
|
|
|
$self->log('INFO', 'No task need to be run currently'); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->_reap_message(); |
58
|
0
|
|
|
|
|
|
$self->_reap_child(); |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ( $self->configval( 'default', 'publish_list' ) ) { |
61
|
0
|
|
|
|
|
|
$self->write_list(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |