MMM/Batch.pm

filter: Statementstmt 37.1% 13 / 35 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 33.3% 19 / 57 CC 9 SCAR 34.3
CC
9
Cov
27%
run
56.0
new
12.0
BEGIN
1.0
CRAP 30.9
« MMM/Utils.pm ↑ Summary MMM/Report/Mail.pm »
1 package MMM::Batch;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw(MMM);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use base qw(MMM::Report::Mail);
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
26 0 my ($class, @args) = @_;
27 0 ▶ my $mmm = $class->SUPER::new(@args) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $mmm = $class->SUPER::new(@args) or return 0 0 0
28  
29 0 ▶ if (!$mmm->{nofork}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mmm->{"nofork"}) 0 0 0
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 0 ▶sub run {
Subroutine run: not called CC=7 SCAR=40.3
Pod documented
38 0 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 ▶ $q->is_disable() and next;
Branch: 1 branch
BranchTrueFalseTotal
$q->is_disable and next 0 0 0
45 0 ▶ $q->frequency or next;
Branch: 1 branch
BranchTrueFalseTotal
$q->frequency or next 0 0 0
46 0 ▶ $q->next_run_time <= scalar(time) or next;
Branch: 1 branch
BranchTrueFalseTotal
$q->next_run_time <= scalar time or next 0 0 0
47 0 push(@started_tasks, $q->name);
48 0 $self->_run_fork($q);
49 }
50  
51 0 ▶ if (@started_tasks) {
Branch: 1 branch
BranchTrueFalseTotal
if (@started_tasks) { } 0 0 0
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 ▶ if ( $self->configval( 'default', 'publish_list' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->configval("default", "publish_list")) 0 0 0
61 0 $self->write_list();
62 }
63 }
64  
65 2 1;
66  
67 __END__
« MMM/Utils.pm ↑ Summary MMM/Report/Mail.pm »