diff options
Diffstat (limited to 'web/attachments/352097-0001-move-nagios_die-out-of-N-P-Thresholds.patch')
-rw-r--r-- | web/attachments/352097-0001-move-nagios_die-out-of-N-P-Thresholds.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/web/attachments/352097-0001-move-nagios_die-out-of-N-P-Thresholds.patch b/web/attachments/352097-0001-move-nagios_die-out-of-N-P-Thresholds.patch new file mode 100644 index 0000000..449cdd9 --- /dev/null +++ b/web/attachments/352097-0001-move-nagios_die-out-of-N-P-Thresholds.patch | |||
@@ -0,0 +1,69 @@ | |||
1 | From c1f379dbeb62b56530a25319690977385ce6766f Mon Sep 17 00:00:00 2001 | ||
2 | From: Danijel Tasov <dt@korn.shell.la> | ||
3 | Date: Sun, 22 Nov 2009 14:25:33 +0100 | ||
4 | Subject: [PATCH] move nagios_die out of N::P::Thresholds. | ||
5 | |||
6 | N::P::Thresholds uses nagios_die. This is suboptimal for using | ||
7 | that Class in other Projects. Though one can set | ||
8 | N::P::F::_use_die, but then $@ contains get_shortname and a | ||
9 | STATUS_TEXT, which feels odd. | ||
10 | |||
11 | Signed-off-by: Danijel Tasov <dt@korn.shell.la> | ||
12 | --- | ||
13 | lib/Nagios/Plugin.pm | 7 ++++++- | ||
14 | lib/Nagios/Plugin/Threshold.pm | 7 ++++--- | ||
15 | 2 files changed, 10 insertions(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm | ||
18 | index 697005a..958d617 100644 | ||
19 | --- a/lib/Nagios/Plugin.pm | ||
20 | +++ b/lib/Nagios/Plugin.pm | ||
21 | @@ -83,7 +83,12 @@ sub all_perfoutput { | ||
22 | sub set_thresholds { | ||
23 | my $self = shift; | ||
24 | require Nagios::Plugin::Threshold; | ||
25 | - return $self->threshold( Nagios::Plugin::Threshold->set_thresholds(@_)); | ||
26 | + eval { | ||
27 | + $self->threshold( Nagios::Plugin::Threshold->set_thresholds(@_)); | ||
28 | + }; if($@) { | ||
29 | + $self->nagios_die($@); | ||
30 | + } | ||
31 | + return $self->threshold; | ||
32 | } | ||
33 | |||
34 | # NP::Functions wrappers | ||
35 | diff --git a/lib/Nagios/Plugin/Threshold.pm b/lib/Nagios/Plugin/Threshold.pm | ||
36 | index 73fce53..e481cd4 100644 | ||
37 | --- a/lib/Nagios/Plugin/Threshold.pm | ||
38 | +++ b/lib/Nagios/Plugin/Threshold.pm | ||
39 | @@ -9,7 +9,8 @@ use base qw(Class::Accessor::Fast); | ||
40 | __PACKAGE__->mk_accessors(qw(warning critical)); | ||
41 | |||
42 | use Nagios::Plugin::Range; | ||
43 | -use Nagios::Plugin::Functions qw(:codes nagios_die); | ||
44 | +use Nagios::Plugin::Functions qw(:codes); | ||
45 | +use Carp; | ||
46 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; | ||
47 | |||
48 | sub get_status | ||
49 | @@ -34,7 +35,7 @@ sub _inflate | ||
50 | |||
51 | # For refs, check isa N::P::Range | ||
52 | if (ref $value) { | ||
53 | - nagios_die("Invalid $key object: type " . ref $value) | ||
54 | + croak("Invalid $key object: type " . ref $value) | ||
55 | unless $value->isa("Nagios::Plugin::Range"); | ||
56 | return $value; | ||
57 | } | ||
58 | @@ -44,7 +45,7 @@ sub _inflate | ||
59 | |||
60 | # Otherwise parse $value | ||
61 | my $range = Nagios::Plugin::Range->parse_range_string($value); | ||
62 | - nagios_die("Cannot parse $key range: '$value'") unless(defined($range)); | ||
63 | + croak("Cannot parse $key range: '$value'") unless(defined($range)); | ||
64 | return $range; | ||
65 | } | ||
66 | |||
67 | -- | ||
68 | 1.6.5.2.10.g754571 | ||
69 | |||