diff options
author | Gavin Carr <gonzai@users.sourceforge.net> | 2006-10-04 22:02:39 +0000 |
---|---|---|
committer | Gavin Carr <gonzai@users.sourceforge.net> | 2006-10-04 22:02:39 +0000 |
commit | e63887eda6765e1059939ff9c89e4fb244b5819b (patch) | |
tree | 3ae2b11db96535bdbd7a8da60fde642a8fd80619 /lib/Nagios | |
parent | 579fdad51ca7c1d306ba040954864216b0e07050 (diff) | |
download | monitoring-plugin-perl-e63887eda6765e1059939ff9c89e4fb244b5819b.tar.gz |
Fix NP shortname defaulting; downgrade version requirements.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1489 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/Nagios')
-rw-r--r-- | lib/Nagios/Plugin.pm | 16 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Functions.pm | 10 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Performance.pm | 2 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Range.pm | 2 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Threshold.pm | 2 |
5 files changed, 23 insertions, 9 deletions
diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm index 5debdbc..29b79b9 100644 --- a/lib/Nagios/Plugin.pm +++ b/lib/Nagios/Plugin.pm | |||
@@ -12,8 +12,6 @@ struct "Nagios::__::Plugin" => { | |||
12 | package Nagios::Plugin; | 12 | package Nagios::Plugin; |
13 | 13 | ||
14 | use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES); | 14 | use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES); |
15 | use Nagios::Plugin::Performance; | ||
16 | use Nagios::Plugin::Threshold; | ||
17 | 15 | ||
18 | use strict; | 16 | use strict; |
19 | use warnings; | 17 | use warnings; |
@@ -29,6 +27,7 @@ our $VERSION = $Nagios::Plugin::Functions::VERSION; | |||
29 | 27 | ||
30 | sub add_perfdata { | 28 | sub add_perfdata { |
31 | my ($self, %args) = @_; | 29 | my ($self, %args) = @_; |
30 | require Nagios::Plugin::Performance; | ||
32 | my $perf = Nagios::Plugin::Performance->new(%args); | 31 | my $perf = Nagios::Plugin::Performance->new(%args); |
33 | push @{$self->perfdata}, $perf; | 32 | push @{$self->perfdata}, $perf; |
34 | } | 33 | } |
@@ -37,7 +36,11 @@ sub all_perfoutput { | |||
37 | return join(" ", map {$_->perfoutput} (@{$self->perfdata})); | 36 | return join(" ", map {$_->perfoutput} (@{$self->perfdata})); |
38 | } | 37 | } |
39 | 38 | ||
40 | sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } | 39 | sub set_thresholds { |
40 | shift; | ||
41 | require Nagios::Plugin::Threshold; | ||
42 | Nagios::Plugin::Threshold->set_thresholds(@_); | ||
43 | } | ||
41 | 44 | ||
42 | # NP::Functions wrappers | 45 | # NP::Functions wrappers |
43 | sub nagios_exit { | 46 | sub nagios_exit { |
@@ -52,6 +55,13 @@ sub die { | |||
52 | my $self = shift; | 55 | my $self = shift; |
53 | Nagios::Plugin::Functions::nagios_die(@_, { plugin => $self }); | 56 | Nagios::Plugin::Functions::nagios_die(@_, { plugin => $self }); |
54 | } | 57 | } |
58 | # Override default shortname accessor to add default | ||
59 | sub shortname { | ||
60 | my $self = shift; | ||
61 | $self->{'Nagios::__::Plugin::shortname'} = shift if @_; | ||
62 | return $self->{'Nagios::__::Plugin::shortname'} || | ||
63 | Nagios::Plugin::Functions::get_shortname(); | ||
64 | } | ||
55 | 65 | ||
56 | # ------------------------------------------------------------------------- | 66 | # ------------------------------------------------------------------------- |
57 | # NP::Functions::check_messages helpers and wrappers | 67 | # NP::Functions::check_messages helpers and wrappers |
diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm index 9cb7eb6..804661c 100644 --- a/lib/Nagios/Plugin/Functions.pm +++ b/lib/Nagios/Plugin/Functions.pm | |||
@@ -1,7 +1,10 @@ | |||
1 | # This module holds all exported variables | 1 | # Functional interface to basic Nagios::Plugin constants, exports, |
2 | # and base functions | 2 | # and functions |
3 | |||
3 | package Nagios::Plugin::Functions; | 4 | package Nagios::Plugin::Functions; |
4 | 5 | ||
6 | use 5.006; | ||
7 | |||
5 | use strict; | 8 | use strict; |
6 | use warnings; | 9 | use warnings; |
7 | use File::Basename; | 10 | use File::Basename; |
@@ -47,7 +50,8 @@ sub get_shortname { | |||
47 | return $arg{plugin}->shortname if $arg{plugin}; | 50 | return $arg{plugin}->shortname if $arg{plugin}; |
48 | 51 | ||
49 | my $shortname = uc basename($ENV{NAGIOS_PLUGIN} || $0); | 52 | my $shortname = uc basename($ENV{NAGIOS_PLUGIN} || $0); |
50 | $shortname =~ s/^CHECK_//; | 53 | $shortname =~ s/^CHECK_//; # Remove any leading CHECK_ |
54 | $shortname =~ s/\..*$//; # Remove any trailing suffix | ||
51 | return $shortname; | 55 | return $shortname; |
52 | } | 56 | } |
53 | 57 | ||
diff --git a/lib/Nagios/Plugin/Performance.pm b/lib/Nagios/Plugin/Performance.pm index 38803a6..512e07d 100644 --- a/lib/Nagios/Plugin/Performance.pm +++ b/lib/Nagios/Plugin/Performance.pm | |||
@@ -1,6 +1,6 @@ | |||
1 | package Nagios::Plugin::Performance; | 1 | package Nagios::Plugin::Performance; |
2 | 2 | ||
3 | use 5.008004; | 3 | use 5.006; |
4 | 4 | ||
5 | use strict; | 5 | use strict; |
6 | use warnings; | 6 | use warnings; |
diff --git a/lib/Nagios/Plugin/Range.pm b/lib/Nagios/Plugin/Range.pm index f354a54..53a857f 100644 --- a/lib/Nagios/Plugin/Range.pm +++ b/lib/Nagios/Plugin/Range.pm | |||
@@ -1,6 +1,6 @@ | |||
1 | package Nagios::Plugin::Range; | 1 | package Nagios::Plugin::Range; |
2 | 2 | ||
3 | use 5.008004; | 3 | use 5.006; |
4 | 4 | ||
5 | use strict; | 5 | use strict; |
6 | use warnings; | 6 | use warnings; |
diff --git a/lib/Nagios/Plugin/Threshold.pm b/lib/Nagios/Plugin/Threshold.pm index 3e14d82..829da66 100644 --- a/lib/Nagios/Plugin/Threshold.pm +++ b/lib/Nagios/Plugin/Threshold.pm | |||
@@ -1,6 +1,6 @@ | |||
1 | package Nagios::Plugin::Threshold; | 1 | package Nagios::Plugin::Threshold; |
2 | 2 | ||
3 | use 5.008004; | 3 | use 5.006; |
4 | 4 | ||
5 | use strict; | 5 | use strict; |
6 | use warnings; | 6 | use warnings; |