line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nagios::Plugin::Threshold::Group; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
457
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6
|
use Carp qw(croak); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
89
|
|
7
|
2
|
|
|
2
|
|
6
|
use Monitoring::Plugin::Functions qw(OK WARNING CRITICAL); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
469
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
7
|
|
|
7
|
0
|
4485
|
my ($class, %args) = @_; |
11
|
|
|
|
|
|
|
|
12
|
7
|
50
|
|
|
|
26
|
my $single_threshold = delete $args{single_threshold} or croak 'single_threshold missed'; |
13
|
7
|
50
|
|
|
|
16
|
my $group_threshold = delete $args{group_threshold} or croak 'group_threshold missed'; |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
|
|
20
|
bless { |
16
|
|
|
|
|
|
|
single_threshold => $single_threshold, |
17
|
|
|
|
|
|
|
group_threshold => $group_threshold, |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_value_status { |
22
|
0
|
|
|
0
|
0
|
0
|
my ($self, $value) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
$self->{single_threshold}->get_status($value); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_status { |
28
|
8
|
|
|
8
|
0
|
633
|
my ($self, $values) = @_; |
29
|
|
|
|
|
|
|
|
30
|
8
|
50
|
|
|
|
20
|
$values = [$values] if ref $values eq ''; |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
10
|
my $st = $self->{single_threshold}; |
33
|
8
|
|
|
|
|
6
|
my $gt = $self->{group_threshold}; |
34
|
|
|
|
|
|
|
|
35
|
8
|
|
|
|
|
21
|
my $s = { |
36
|
|
|
|
|
|
|
Monitoring::Plugin::Functions::OK => 0, |
37
|
|
|
|
|
|
|
Monitoring::Plugin::Functions::WARNING => 0, |
38
|
|
|
|
|
|
|
Monitoring::Plugin::Functions::CRITICAL => 0, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
8
|
|
|
|
|
13
|
foreach my $value (@$values) { |
42
|
28
|
|
|
|
|
772
|
$s->{$st->get_status($value)}++; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
8
|
|
|
|
|
287
|
my $criticals = $s->{Monitoring::Plugin::Functions::CRITICAL}; |
46
|
8
|
|
|
|
|
16
|
my $status = $gt->get_status($criticals); |
47
|
8
|
100
|
|
|
|
327
|
return $status if $status != OK; |
48
|
|
|
|
|
|
|
|
49
|
4
|
50
|
|
|
|
9
|
if ($gt->warning->is_set) { |
50
|
4
|
|
|
|
|
25
|
my $warnings = $s->{Monitoring::Plugin::Functions::WARNING}; |
51
|
4
|
100
|
|
|
|
9
|
return WARNING if $gt->warning->check_range($warnings + $criticals); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
OK |
55
|
3
|
|
|
|
|
52
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |