[Nagiosplug-checkins] Nagios-Plugin/lib/Nagios Plugin.pm, 1.12, 1.13

Gavin Carr gonzai at users.sourceforge.net
Thu Oct 5 00:02:41 CEST 2006


Update of /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26225/lib/Nagios

Modified Files:
	Plugin.pm 
Log Message:
Fix NP shortname defaulting; downgrade version requirements.

Index: Plugin.pm
===================================================================
RCS file: /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Plugin.pm	4 Oct 2006 10:14:11 -0000	1.12
+++ Plugin.pm	4 Oct 2006 22:02:39 -0000	1.13
@@ -12,8 +12,6 @@
 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 @@
 
 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 @@
     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 @@
     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





More information about the Commits mailing list