line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## |
2
|
|
|
|
|
|
|
## Detect System Inactivity |
3
|
|
|
|
|
|
|
## Author: Vipul Ved Prakash . |
4
|
|
|
|
|
|
|
## $Id: Inactivity.pm,v 1.3 2004/07/15 21:11:08 hackworth Exp $ |
5
|
|
|
|
|
|
|
## |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Schedule::Chronic::Constraint::Inactivity; |
8
|
1
|
|
|
1
|
|
450
|
use Schedule::Chronic::Base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
9
|
1
|
|
|
1
|
|
5
|
use Schedule::Chronic::Constraint::Loadavg; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
10
|
1
|
|
|
1
|
|
4
|
use Schedule::Chronic::Constraint::DiskIO; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
11
|
1
|
|
|
1
|
|
4
|
use base qw(Schedule::Chronic::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
291
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
return bless { |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
loadavg => new Schedule::Chronic::Constraint::Loadavg ($debug), |
21
|
|
|
|
|
|
|
diskio => new Schedule::Chronic::Constraint::DiskIO ($debug), |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# This class doesn't have its own timer. Timers are maintained by |
24
|
|
|
|
|
|
|
# DiskIO and Loadavg. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
}, shift |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub init { |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
0
|
|
my ($self, $schedule, $task, $logger, $active) = @_; |
34
|
0
|
0
|
|
|
|
|
return unless ref $self; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$$self{loadavg}->init($schedule, $task, $logger, $active); |
37
|
0
|
|
|
|
|
|
$$self{diskio}->init($schedule, $task, $logger, $active); |
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
|
0
|
0
|
|
|
|
if ($self->{loadavg}->met() && $self->{diskio}->met()) { |
50
|
0
|
|
|
|
|
|
return 1; |
51
|
|
|
|
|
|
|
} else { |
52
|
0
|
|
|
|
|
|
return 0; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub state { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# This is a "Container Constraint" that doesn't have a state of its |
61
|
|
|
|
|
|
|
# own, so we return undef. This is an indication to the poller that |
62
|
|
|
|
|
|
|
# the constraint doesn't have a state. |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
0
|
|
return; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub wait { |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
my $loadavg_wait = $self->{loadavg}->wait(); |
73
|
0
|
|
|
|
|
|
my $diskio_wait = $self->{diskio}->wait(); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
return $loadavg_wait > $diskio_wait ? $loadavg_wait : $diskio_wait; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|