lib/Schedule/Chronic/Constraint/DiskIO.pm

filter: Statementstmt 26.3% 10 / 38 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 5 totaltotal 17.5% 13 / 74 CC 11 SCAR 34.2
CC
11
Cov
17%
init
56.0
met
30.0
new
2.0
CRAP 30.6
« lib/Schedule/Chronic.pm ↑ Summary lib/Schedule/Chronic/Constraint/Loadavg.pm »
1 ##
2 ## DiskIO constraint
3 ## Author: Vipul Ved Prakash <mail@vipul.net>.
4 ## $Id: DiskIO.pm,v 1.6 2004/08/15 21:01:48 hackworth Exp $
5 ##
6  
7  
8 package Schedule::Chronic::Constraint::DiskIO;
9 1 ▶use Schedule::Chronic::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Schedule::Chronic::Timer;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use base qw(Schedule::Chronic::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
15
16 0 my ($class) = @_;
17  
18 0 return bless {
19 bi_threshold => 5,
20 bo_threshold => 5,
21 active => 10,
22 timer => new Schedule::Chronic::Timer ('down'),
23 }, $class;
24  
25 }
26  
27  
28 0 ▶sub init {
Subroutine init: not called CC=7 SCAR=40.3
Pod undocumented
29  
30 0 my ($self, $schedule, $task, $logger, $active, $bi_threshold, $bo_threshold) = @_;
31 0 ▶ return unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
32  
33 0 ▶ $$self{schedule} = $schedule if $schedule;
Branch: 1 branch
BranchTrueFalseTotal
if $schedule 0 0 0
34 0 ▶ $$self{task} = $task if $task;
Branch: 1 branch
BranchTrueFalseTotal
if $task 0 0 0
35 0 ▶ $$self{active} = $active if $active;
Branch: 1 branch
BranchTrueFalseTotal
if $active 0 0 0
36 0 ▶ $$self{bi_threshold} = $bi_threshold if $bi_threshold;
Branch: 1 branch
BranchTrueFalseTotal
if $bi_threshold 0 0 0
37 0 ▶ $$self{bo_threshold} = $bo_threshold if $bo_threshold;
Branch: 1 branch
BranchTrueFalseTotal
if $bo_threshold 0 0 0
38 0 $$self{logger} = $logger;
39  
40 0 return $self;
41  
42 }
43  
44  
45 0 ▶sub met {
Subroutine met: not called CC=5 SCAR=34.0
Pod undocumented
46  
47 0 my ($self) = @_;
48  
49 0 my ($bi, $bo) = $self->state();
50  
51 $self->debug("DiskIO: buffers in = $bi ($$self{bi_threshold}), " .
52 0 "buffers out = $bo ($$self{bo_threshold}), timer = " . $$self{timer}->get());
53  
54 0 ▶ if ($bo <= $$self{bo_threshold} and $bi <= $$self{bi_threshold} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bo <= $self->{"bo_threshold"} and $bi <= $self->{"bi_threshold"}) 0 0 0
Condition0%0/3
$bo <= $self->{"bo_threshold"} and $bi <= $self->{"bi_threshold"}
!ll&&!rl&&r
000
MC/DC0%0/2
$bo <= $self->{"bo_threshold"} and $bi <= $self->{"bi_threshold"}
$bo <= $self->{"bo_threshold"} $bi <= $self->{"bi_threshold"}
Truth table0%0/3
A and B
A= $bo <= $self->{"bo_threshold"}B= $bi <= $self->{"bi_threshold"}
ABresult
0X0
100
111
55  
56 $$self{timer}->set($$self{active}) unless
57 0 ▶ $$self{timer}->running();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"timer"}->running 0 0 0
58  
59 0 ▶ if ($$self{timer}->get() <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'timer'}->get <= 0) { } 0 0 0
60 0 return 1;
61 } else {
62 0 return 0;
63 }
64  
65 }
66  
67 0 $$self{timer}->stop();
68 0 return 0;
69  
70 }
71  
72  
73 0 ▶sub state {
Subroutine state: not called CC=1 SCAR=6.9
Pod undocumented
74  
75 0 my ($self) = @_;
76  
77 # Should we use the proc file system (/proc/stat) to gather
78 # this information? Doesn't seem like a good idea to depend
79 # on existence of vmstat. On the other hand for OSes that
80 # don't have a proc filesystem, vmstat might be more
81 # dependable. This requires more research.
82  
83 0 my @vmstat = `vmstat 1 2`;
84  
85 0 my $io = $vmstat[3];
86 0 $io =~ s/^\s+//;
87 0 my @stats = split /\s+/, $io;
88  
89 0 return ($stats[8], $stats[9]);
90  
91 }
92  
93  
94 0 ▶sub wait {
Subroutine wait: not called CC=1 SCAR=6.9
Pod undocumented
95  
96 0 return 0;
97  
98 }
99  
100  
101 1 1;
102  
103  
« lib/Schedule/Chronic.pm ↑ Summary lib/Schedule/Chronic/Constraint/Loadavg.pm »