diff options
Diffstat (limited to 'lib/Nagios/Plugin/Threshold.pm')
-rw-r--r-- | lib/Nagios/Plugin/Threshold.pm | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/Nagios/Plugin/Threshold.pm b/lib/Nagios/Plugin/Threshold.pm index 9e7b938..d7a8177 100644 --- a/lib/Nagios/Plugin/Threshold.pm +++ b/lib/Nagios/Plugin/Threshold.pm | |||
@@ -6,7 +6,7 @@ use strict; | |||
6 | use warnings; | 6 | use warnings; |
7 | 7 | ||
8 | use Nagios::Plugin::Range; | 8 | use Nagios::Plugin::Range; |
9 | use Nagios::Plugin::Base; | 9 | use Nagios::Plugin::Base qw(:codes nagios_die); |
10 | our ($VERSION) = $Nagios::Plugin::Base::VERSION; | 10 | our ($VERSION) = $Nagios::Plugin::Base::VERSION; |
11 | 11 | ||
12 | use Class::Struct; | 12 | use Class::Struct; |
@@ -23,10 +23,7 @@ sub set_thresholds { | |||
23 | if (defined $r) { | 23 | if (defined $r) { |
24 | $t->warning($r); | 24 | $t->warning($r); |
25 | } else { | 25 | } else { |
26 | Nagios::Plugin::Base->die( { | 26 | nagios_die( "Warning range incorrect: '$args{warning}'" ); |
27 | return_code => $ERRORS{UNKNOWN}, | ||
28 | message => "Warning range incorrect: '$args{warning}'" | ||
29 | } ); | ||
30 | } | 27 | } |
31 | } | 28 | } |
32 | if (defined $args{critical}) { | 29 | if (defined $args{critical}) { |
@@ -34,10 +31,7 @@ sub set_thresholds { | |||
34 | if (defined $r) { | 31 | if (defined $r) { |
35 | $t->critical($r); | 32 | $t->critical($r); |
36 | } else { | 33 | } else { |
37 | Nagios::Plugin::Base->die( { | 34 | nagios_die( "Critical range incorrect: '$args{critical}'" ); |
38 | return_code => $ERRORS{UNKNOWN}, | ||
39 | message => "Critical range incorrect: '$args{critical}'" | ||
40 | } ); | ||
41 | } | 35 | } |
42 | } | 36 | } |
43 | return $t; | 37 | return $t; |
@@ -48,15 +42,15 @@ sub get_status { | |||
48 | 42 | ||
49 | if ($self->critical->is_set) { | 43 | if ($self->critical->is_set) { |
50 | if ($self->critical->check_range($value) == 1) { | 44 | if ($self->critical->check_range($value) == 1) { |
51 | return $ERRORS{CRITICAL}; | 45 | return CRITICAL; |
52 | } | 46 | } |
53 | } | 47 | } |
54 | if ($self->warning->is_set) { | 48 | if ($self->warning->is_set) { |
55 | if ($self->warning->check_range($value) == 1) { | 49 | if ($self->warning->check_range($value) == 1) { |
56 | return $ERRORS{WARNING}; | 50 | return WARNING; |
57 | } | 51 | } |
58 | } | 52 | } |
59 | return $ERRORS{OK}; | 53 | return OK; |
60 | } | 54 | } |
61 | 55 | ||
62 | 1; | 56 | 1; |
@@ -81,7 +75,7 @@ Returns the warning or critical range as a Nagios::Plugin::Range object. | |||
81 | 75 | ||
82 | =item get_status($value) | 76 | =item get_status($value) |
83 | 77 | ||
84 | Given a value, will see if the value breeches the critical or the warning range. Returns the status code. | 78 | Given a value, will see if the value breaches the critical or the warning range. Returns the status code. |
85 | 79 | ||
86 | =back | 80 | =back |
87 | 81 | ||