line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nagios::Plugin::Threshold::Group; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
451
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
40
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6
|
use Carp qw(croak); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
76
|
|
7
|
2
|
|
|
2
|
|
7
|
use Monitoring::Plugin::Functions qw(OK WARNING CRITICAL); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
463
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
7
|
|
|
7
|
0
|
3846
|
my ($class, %args) = @_; |
11
|
|
|
|
|
|
|
|
12
|
7
|
50
|
|
|
|
21
|
my $single_threshold = delete $args{single_threshold} or croak 'single_threshold missed'; |
13
|
7
|
50
|
|
|
|
14
|
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
|
712
|
my ($self, $values) = @_; |
29
|
|
|
|
|
|
|
|
30
|
8
|
50
|
|
|
|
19
|
$values = [$values] if ref $values eq ''; |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
9
|
my $st = $self->{single_threshold}; |
33
|
8
|
|
|
|
|
7
|
my $gt = $self->{group_threshold}; |
34
|
|
|
|
|
|
|
|
35
|
8
|
|
|
|
|
17
|
my $s = { |
36
|
|
|
|
|
|
|
Monitoring::Plugin::Functions::OK => 0, |
37
|
|
|
|
|
|
|
Monitoring::Plugin::Functions::WARNING => 0, |
38
|
|
|
|
|
|
|
Monitoring::Plugin::Functions::CRITICAL => 0, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
8
|
|
|
|
|
8
|
foreach my $value (@$values) { |
42
|
28
|
|
|
|
|
733
|
$s->{$st->get_status($value)}++; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
8
|
|
|
|
|
306
|
my $criticals = $s->{Monitoring::Plugin::Functions::CRITICAL}; |
46
|
8
|
|
|
|
|
35
|
my $status = $gt->get_status($criticals); |
47
|
8
|
100
|
|
|
|
300
|
return $status if $status != OK; |
48
|
|
|
|
|
|
|
|
49
|
4
|
50
|
|
|
|
8
|
if ($gt->warning->is_set) { |
50
|
4
|
|
|
|
|
24
|
my $warnings = $s->{Monitoring::Plugin::Functions::WARNING}; |
51
|
4
|
100
|
|
|
|
8
|
return WARNING if $gt->warning->check_range($warnings + $criticals); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
OK |
55
|
3
|
|
|
|
|
49
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |