line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nagios::Plugin::Threshold; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
40024
|
use 5.006; |
|
6
|
|
|
|
|
52
|
|
|
6
|
|
|
|
|
292
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
46
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
259
|
|
6
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
261
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
33
|
use base qw(Class::Accessor::Fast); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1691
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(warning critical)); |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
8638
|
use Nagios::Plugin::Range; |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
75
|
|
12
|
6
|
|
|
6
|
|
217
|
use Nagios::Plugin::Functions qw(:codes nagios_die); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
3961
|
|
13
|
|
|
|
|
|
|
our ($VERSION) = $Nagios::Plugin::Functions::VERSION; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_status |
16
|
|
|
|
|
|
|
{ |
17
|
68
|
|
|
68
|
0
|
13256
|
my ($self, $value) = @_; |
18
|
|
|
|
|
|
|
|
19
|
68
|
100
|
|
|
|
325
|
$value = [ $value ] if (ref $value eq ""); |
20
|
68
|
|
|
|
|
134
|
foreach my $v (@$value) { |
21
|
76
|
100
|
|
|
|
342
|
if ($self->critical->is_set) { |
22
|
64
|
100
|
|
|
|
523
|
return CRITICAL if $self->critical->check_range($v); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
49
|
|
|
|
|
423
|
foreach my $v (@$value) { |
26
|
50
|
100
|
|
|
|
418
|
if ($self->warning->is_set) { |
27
|
42
|
100
|
|
|
|
327
|
return WARNING if $self->warning->check_range($v); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
26
|
|
|
|
|
334
|
return OK; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _inflate |
34
|
|
|
|
|
|
|
{ |
35
|
224
|
|
|
224
|
|
536
|
my ($self, $value, $key) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Return an undefined range if $value is undef |
38
|
224
|
100
|
|
|
|
559
|
return Nagios::Plugin::Range->new if ! defined $value; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# For refs, check isa N::P::Range |
41
|
193
|
100
|
|
|
|
404
|
if (ref $value) { |
42
|
3
|
50
|
|
|
|
26
|
nagios_die("Invalid $key object: type " . ref $value) |
43
|
|
|
|
|
|
|
unless $value->isa("Nagios::Plugin::Range"); |
44
|
3
|
|
|
|
|
16
|
return $value; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Another quick exit if $value is an empty string |
48
|
190
|
100
|
|
|
|
414
|
return Nagios::Plugin::Range->new if $value eq ""; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Otherwise parse $value |
51
|
184
|
|
|
|
|
661
|
my $range = Nagios::Plugin::Range->parse_range_string($value); |
52
|
184
|
50
|
|
|
|
638
|
nagios_die("Cannot parse $key range: '$value'") unless(defined($range)); |
53
|
184
|
|
|
|
|
899
|
return $range; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set_thresholds |
57
|
|
|
|
|
|
|
{ |
58
|
112
|
|
|
112
|
0
|
1161
|
my ($self, %arg) = @_; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Equals new() as a class method |
61
|
112
|
100
|
|
|
|
600
|
return $self->new(%arg) unless ref $self; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# On an object, just acts as special mutator |
64
|
2
|
|
|
|
|
19
|
$self->set($_, $arg{$_}) foreach qw(warning critical); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set |
68
|
|
|
|
|
|
|
{ |
69
|
4
|
|
|
4
|
1
|
34
|
my $self = shift; |
70
|
4
|
|
|
|
|
7
|
my ($key, $value) = @_; |
71
|
4
|
|
|
|
|
14
|
$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
|
282
|
my ($self, %arg) = @_; |
78
|
220
|
|
|
|
|
921
|
$self->SUPER::new({ |
79
|
110
|
|
|
|
|
235
|
map { $_ => $self->_inflate($arg{$_}, $_) } qw(warning critical) |
80
|
|
|
|
|
|
|
}); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |