line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## |
2
|
|
|
|
|
|
|
## DiskIO constraint |
3
|
|
|
|
|
|
|
## Author: Vipul Ved Prakash . |
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
|
|
|
1
|
|
430
|
use Schedule::Chronic::Base; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
10
|
1
|
|
|
1
|
|
4
|
use Schedule::Chronic::Timer; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
11
|
1
|
|
|
1
|
|
4
|
use base qw(Schedule::Chronic::Base); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
418
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub init { |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
0
|
|
my ($self, $schedule, $task, $logger, $active, $bi_threshold, $bo_threshold) = @_; |
31
|
0
|
0
|
|
|
|
|
return unless $self; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
$$self{schedule} = $schedule if $schedule; |
34
|
0
|
0
|
|
|
|
|
$$self{task} = $task if $task; |
35
|
0
|
0
|
|
|
|
|
$$self{active} = $active if $active; |
36
|
0
|
0
|
|
|
|
|
$$self{bi_threshold} = $bi_threshold if $bi_threshold; |
37
|
0
|
0
|
|
|
|
|
$$self{bo_threshold} = $bo_threshold if $bo_threshold; |
38
|
0
|
|
|
|
|
|
$$self{logger} = $logger; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return $self; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub met { |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my ($bi, $bo) = $self->state(); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$self->debug("DiskIO: buffers in = $bi ($$self{bi_threshold}), " . |
52
|
|
|
|
|
|
|
"buffers out = $bo ($$self{bo_threshold}), timer = " . $$self{timer}->get()); |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
if ($bo <= $$self{bo_threshold} and $bi <= $$self{bi_threshold} ) { |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
$$self{timer}->set($$self{active}) unless |
57
|
|
|
|
|
|
|
$$self{timer}->running(); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ($$self{timer}->get() <= 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
|
|
|
|
|
|
|
sub state { |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub wait { |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
0
|
|
return 0; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|