From e63887eda6765e1059939ff9c89e4fb244b5819b Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Wed, 4 Oct 2006 22:02:39 +0000 Subject: 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 --- lib/Nagios/Plugin.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/Nagios/Plugin.pm') 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" => { package Nagios::Plugin; use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES); -use Nagios::Plugin::Performance; -use Nagios::Plugin::Threshold; use strict; use warnings; @@ -29,6 +27,7 @@ our $VERSION = $Nagios::Plugin::Functions::VERSION; sub add_perfdata { my ($self, %args) = @_; + require Nagios::Plugin::Performance; my $perf = Nagios::Plugin::Performance->new(%args); push @{$self->perfdata}, $perf; } @@ -37,7 +36,11 @@ sub all_perfoutput { return join(" ", map {$_->perfoutput} (@{$self->perfdata})); } -sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } +sub set_thresholds { + shift; + require Nagios::Plugin::Threshold; + Nagios::Plugin::Threshold->set_thresholds(@_); +} # NP::Functions wrappers sub nagios_exit { @@ -52,6 +55,13 @@ sub die { my $self = shift; Nagios::Plugin::Functions::nagios_die(@_, { plugin => $self }); } +# Override default shortname accessor to add default +sub shortname { + my $self = shift; + $self->{'Nagios::__::Plugin::shortname'} = shift if @_; + return $self->{'Nagios::__::Plugin::shortname'} || + Nagios::Plugin::Functions::get_shortname(); +} # ------------------------------------------------------------------------- # NP::Functions::check_messages helpers and wrappers -- cgit v1.2.3-74-g34f1