line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
63487
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
149
|
|
2
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
161
|
|
3
|
|
|
|
|
|
|
package Juno; |
4
|
|
|
|
|
|
|
# ABSTRACT: Asynchronous event-driven checking mechanism |
5
|
|
|
|
|
|
|
$Juno::VERSION = '0.010'; |
6
|
4
|
|
|
4
|
|
1848
|
use Moo; |
|
4
|
|
|
|
|
35705
|
|
|
4
|
|
|
|
|
21
|
|
7
|
4
|
|
|
4
|
|
5902
|
use MooX::Types::MooseLike::Base qw; |
|
4
|
|
|
|
|
16018
|
|
|
4
|
|
|
|
|
369
|
|
8
|
4
|
|
|
4
|
|
1643
|
use Sub::Quote; |
|
4
|
|
|
|
|
8494
|
|
|
4
|
|
|
|
|
247
|
|
9
|
4
|
|
|
4
|
|
1992
|
use Class::Load 'load_class'; |
|
4
|
|
|
|
|
69865
|
|
|
4
|
|
|
|
|
312
|
|
10
|
4
|
|
|
4
|
|
1746
|
use namespace::sweep; |
|
4
|
|
|
|
|
31718
|
|
|
4
|
|
|
|
|
26
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'MooseX::Role::Loggable'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has hosts => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
17
|
|
|
|
|
|
|
default => sub { [] }, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has interval => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => Num, |
23
|
|
|
|
|
|
|
default => sub {10}, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has after => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => Num, |
29
|
|
|
|
|
|
|
default => sub {0}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has prop_attributes => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
35
|
|
|
|
|
|
|
default => sub { [ qw ] }, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has checks => ( |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => HashRef[HashRef], |
41
|
|
|
|
|
|
|
required => 1, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has check_objects => ( |
45
|
|
|
|
|
|
|
is => 'lazy', |
46
|
|
|
|
|
|
|
isa => ArrayRef, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _build_check_objects { |
50
|
4
|
|
|
4
|
|
1020
|
my $self = shift; |
51
|
4
|
|
|
|
|
8
|
my %checks = %{ $self->checks }; |
|
4
|
|
|
|
|
22
|
|
52
|
4
|
|
|
|
|
9
|
my @checks = (); |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
12
|
foreach my $check ( keys %checks ) { |
55
|
4
|
|
|
|
|
8
|
my $class = "Juno::Check::$check"; |
56
|
4
|
|
|
|
|
26
|
load_class($class); |
57
|
|
|
|
|
|
|
|
58
|
4
|
|
|
|
|
328
|
my %check_data = %{ $checks{$check} }; |
|
4
|
|
|
|
|
17
|
|
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
8
|
foreach my $prop_key ( @{ $self->prop_attributes } ) { |
|
4
|
|
|
|
|
18
|
|
61
|
12
|
100
|
|
|
|
53
|
exists $check_data{$prop_key} |
62
|
|
|
|
|
|
|
or $check_data{$prop_key} = $self->$prop_key; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
4
|
|
|
|
|
25
|
push @checks, $class->new( |
66
|
|
|
|
|
|
|
%check_data, |
67
|
|
|
|
|
|
|
logger => $self->logger, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
71642
|
return \@checks; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub run { |
75
|
5
|
|
|
5
|
1
|
3417
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
5
|
|
|
|
|
10
|
foreach my $check ( @{ $self->check_objects } ) { |
|
5
|
|
|
|
|
64
|
|
78
|
5
|
|
|
|
|
673
|
$self->log( 'Running', ref $check ); |
79
|
5
|
|
|
|
|
23609
|
$check->run(); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |