| 1 | ## | ||||||||||||||||||||||||||||
| 2 | ## Detect System Inactivity | ||||||||||||||||||||||||||||
| 3 | ## Author: Vipul Ved Prakash <mail@vipul.net>. | ||||||||||||||||||||||||||||
| 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 | ▶ | use Schedule::Chronic::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Schedule::Chronic::Constraint::Loadavg; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Schedule::Chronic::Constraint::DiskIO; | ||||||||||||||||||||||||||
|
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 | |||||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my ($self, $schedule, $task, $logger, $active) = @_; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | return unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub met { | ||||||||||||||||||||||||||
|
Subroutine
met: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($self->{loadavg}->met() && $self->{diskio}->met()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"loadavg"}->met and $self->{"diskio"}->met
MC/DC0%0/2
$self->{"loadavg"}->met and $self->{"diskio"}->met
$self->{"loadavg"}->met
$self->{"diskio"}->met
Truth table0%0/3
A and B
A= $self->{"loadavg"}->metB= $self->{"diskio"}->met
| |||||||||||||||||||||||||||||
| 50 | 0 | return 1; | |||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||
| 52 | 0 | return 0; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub state { | ||||||||||||||||||||||||||
|
Subroutine
state: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 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 | return; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub wait { | ||||||||||||||||||||||||||
|
Subroutine
wait: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 72 | 0 | my $loadavg_wait = $self->{loadavg}->wait(); | |||||||||||||||||||||||||||
| 73 | 0 | my $diskio_wait = $self->{diskio}->wait(); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return $loadavg_wait > $diskio_wait ? $loadavg_wait : $diskio_wait; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | 1; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||