summaryrefslogtreecommitdiffstats
path: root/lib/Nagios
diff options
context:
space:
mode:
authorGavin Carr <gonzai@users.sourceforge.net>2006-10-04 22:02:39 +0000
committerGavin Carr <gonzai@users.sourceforge.net>2006-10-04 22:02:39 +0000
commite63887eda6765e1059939ff9c89e4fb244b5819b (patch)
tree3ae2b11db96535bdbd7a8da60fde642a8fd80619 /lib/Nagios
parent579fdad51ca7c1d306ba040954864216b0e07050 (diff)
downloadmonitoring-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.pm16
-rw-r--r--lib/Nagios/Plugin/Functions.pm10
-rw-r--r--lib/Nagios/Plugin/Performance.pm2
-rw-r--r--lib/Nagios/Plugin/Range.pm2
-rw-r--r--lib/Nagios/Plugin/Threshold.pm2
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" => {
12package Nagios::Plugin; 12package Nagios::Plugin;
13 13
14use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES); 14use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES);
15use Nagios::Plugin::Performance;
16use Nagios::Plugin::Threshold;
17 15
18use strict; 16use strict;
19use warnings; 17use warnings;
@@ -29,6 +27,7 @@ our $VERSION = $Nagios::Plugin::Functions::VERSION;
29 27
30sub add_perfdata { 28sub 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
40sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } 39sub 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
43sub nagios_exit { 46sub 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
59sub 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
3package Nagios::Plugin::Functions; 4package Nagios::Plugin::Functions;
4 5
6use 5.006;
7
5use strict; 8use strict;
6use warnings; 9use warnings;
7use File::Basename; 10use 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 @@
1package Nagios::Plugin::Performance; 1package Nagios::Plugin::Performance;
2 2
3use 5.008004; 3use 5.006;
4 4
5use strict; 5use strict;
6use warnings; 6use 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 @@
1package Nagios::Plugin::Range; 1package Nagios::Plugin::Range;
2 2
3use 5.008004; 3use 5.006;
4 4
5use strict; 5use strict;
6use warnings; 6use 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 @@
1package Nagios::Plugin::Threshold; 1package Nagios::Plugin::Threshold;
2 2
3use 5.008004; 3use 5.006;
4 4
5use strict; 5use strict;
6use warnings; 6use warnings;