line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nagios::Monitoring::Plugin::Threshold;
|
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
25219
|
use 5.006;
|
|
6
|
|
|
|
|
22
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
37
|
use strict;
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
134
|
|
6
|
6
|
|
|
6
|
|
24
|
use warnings;
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
215
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
28
|
use base qw(Class::Accessor::Fast);
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1473
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(warning critical));
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
8065
|
use Nagios::Monitoring::Plugin::Range;
|
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
65
|
|
12
|
6
|
|
|
6
|
|
220
|
use Nagios::Monitoring::Plugin::Functions qw(:codes nagios_die);
|
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
3635
|
|
13
|
|
|
|
|
|
|
our ($VERSION) = $Nagios::Monitoring::Plugin::Functions::VERSION;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_status
|
16
|
|
|
|
|
|
|
{
|
17
|
68
|
|
|
68
|
0
|
7535
|
my ($self, $value) = @_;
|
18
|
|
|
|
|
|
|
|
19
|
68
|
100
|
|
|
|
234
|
$value = [ $value ] if (ref $value eq "");
|
20
|
68
|
|
|
|
|
122
|
foreach my $v (@$value) {
|
21
|
76
|
100
|
|
|
|
212
|
if ($self->critical->is_set) {
|
22
|
64
|
100
|
|
|
|
490
|
return CRITICAL if $self->critical->check_range($v);
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
}
|
25
|
49
|
|
|
|
|
157
|
foreach my $v (@$value) {
|
26
|
50
|
100
|
|
|
|
121
|
if ($self->warning->is_set) {
|
27
|
42
|
100
|
|
|
|
315
|
return WARNING if $self->warning->check_range($v);
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
}
|
30
|
26
|
|
|
|
|
200
|
return OK;
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _inflate
|
34
|
|
|
|
|
|
|
{
|
35
|
224
|
|
|
224
|
|
332
|
my ($self, $value, $key) = @_;
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Return an undefined range if $value is undef
|
38
|
224
|
100
|
|
|
|
500
|
return Nagios::Monitoring::Plugin::Range->new if ! defined $value;
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# For refs, check isa N::P::Range
|
41
|
193
|
100
|
|
|
|
356
|
if (ref $value) {
|
42
|
3
|
50
|
|
|
|
22
|
nagios_die("Invalid $key object: type " . ref $value)
|
43
|
|
|
|
|
|
|
unless $value->isa("Nagios::Monitoring::Plugin::Range");
|
44
|
3
|
|
|
|
|
15
|
return $value;
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Another quick exit if $value is an empty string
|
48
|
190
|
100
|
|
|
|
378
|
return Nagios::Monitoring::Plugin::Range->new if $value eq "";
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Otherwise parse $value
|
51
|
184
|
|
|
|
|
537
|
my $range = Nagios::Monitoring::Plugin::Range->parse_range_string($value);
|
52
|
184
|
50
|
|
|
|
426
|
nagios_die("Cannot parse $key range: '$value'") unless(defined($range));
|
53
|
184
|
|
|
|
|
697
|
return $range;
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set_thresholds
|
57
|
|
|
|
|
|
|
{
|
58
|
112
|
|
|
112
|
0
|
941
|
my ($self, %arg) = @_;
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Equals new() as a class method
|
61
|
112
|
100
|
|
|
|
476
|
return $self->new(%arg) unless ref $self;
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# On an object, just acts as special mutator
|
64
|
2
|
|
|
|
|
10
|
$self->set($_, $arg{$_}) foreach qw(warning critical);
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set
|
68
|
|
|
|
|
|
|
{
|
69
|
4
|
|
|
4
|
1
|
27
|
my $self = shift;
|
70
|
4
|
|
|
|
|
7
|
my ($key, $value) = @_;
|
71
|
4
|
|
|
|
|
11
|
$self->SUPER::set($key, $self->_inflate($value, $key));
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Constructor - inflate scalars to N::P::Range objects
|
75
|
|
|
|
|
|
|
sub new
|
76
|
|
|
|
|
|
|
{
|
77
|
110
|
|
|
110
|
1
|
237
|
my ($self, %arg) = @_;
|
78
|
|
|
|
|
|
|
$self->SUPER::new({
|
79
|
110
|
|
|
|
|
198
|
map { $_ => $self->_inflate($arg{$_}, $_) } qw(warning critical)
|
|
220
|
|
|
|
|
639
|
|
80
|
|
|
|
|
|
|
});
|
81
|
|
|
|
|
|
|
}
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1;
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__
|