r56273 - in /branches/upstream/libnagios-plugin-perl/current: Changes META.yml lib/Nagios/Plugin.pm lib/Nagios/Plugin/Functions.pm lib/Nagios/Plugin/Getopt.pm t/Nagios-Plugin-01.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sat Apr 17 07:14:05 UTC 2010


Author: ansgar-guest
Date: Sat Apr 17 07:13:10 2010
New Revision: 56273

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56273
Log:
[svn-upgrade] Integrating new upstream version, libnagios-plugin-perl (0.34)

Modified:
    branches/upstream/libnagios-plugin-perl/current/Changes
    branches/upstream/libnagios-plugin-perl/current/META.yml
    branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin.pm
    branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Functions.pm
    branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Getopt.pm
    branches/upstream/libnagios-plugin-perl/current/t/Nagios-Plugin-01.t

Modified: branches/upstream/libnagios-plugin-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnagios-plugin-perl/current/Changes?rev=56273&op=diff
==============================================================================
--- branches/upstream/libnagios-plugin-perl/current/Changes (original)
+++ branches/upstream/libnagios-plugin-perl/current/Changes Sat Apr 17 07:13:10 2010
@@ -1,4 +1,9 @@
 Revision history for Perl module Nagios::Plugin.
+
+0.34 15th April 2010
+  - Amended standard --extra-opts help
+  - pod fix (Frank Wiegand - RT51872)
+  - Added %STATUS_TEXT to valid possible exports (Andrew Ford - RT46048)
 
 0.33 5th June 2009
   - Fixed infinite loop when invalid performance data with multiple = were present

Modified: branches/upstream/libnagios-plugin-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnagios-plugin-perl/current/META.yml?rev=56273&op=diff
==============================================================================
--- branches/upstream/libnagios-plugin-perl/current/META.yml (original)
+++ branches/upstream/libnagios-plugin-perl/current/META.yml Sat Apr 17 07:13:10 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Nagios-Plugin
-version:            0.33
+version:            0.34
 abstract:           A family of perl modules to streamline writing Nagios 
 author:
     - Nagios Plugin Development Team <nagiosplug-devel at lists.sourceforge.net>
@@ -24,7 +24,7 @@
     directory:
         - t
         - inc
-generated_by:       ExtUtils::MakeMaker version 6.50
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
     version:  1.4

Modified: branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin.pm?rev=56273&op=diff
==============================================================================
--- branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin.pm (original)
+++ branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin.pm Sat Apr 17 07:13:10 2010
@@ -11,6 +11,7 @@
 use base qw(Class::Accessor::Fast);
 
 Nagios::Plugin->mk_accessors(qw(
+								shortname
 								perfdata 
 								messages 
 								opts
@@ -20,12 +21,12 @@
 use Exporter;
 our @ISA = qw(Exporter);
 our @EXPORT = (@STATUS_CODES);
-our @EXPORT_OK = qw(%ERRORS);
+our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT);
 
 # CPAN stupidly won't index this module without a literal $VERSION here,
 #   so we're forced to duplicate it explicitly
 # Make sure you update $Nagios::Plugin::Functions::VERSION too
-our $VERSION = "0.33";
+our $VERSION = "0.34";
 
 sub new {
 	my $class = shift;
@@ -45,11 +46,8 @@
 		},
 	);
 
-	my $shortname = undef;
-	if (exists $args{shortname}) {
-		$shortname = $args{shortname};
-		delete $args{shortname};
-	}
+	my $shortname = Nagios::Plugin::Functions::get_shortname(\%args);
+	delete $args{shortname} if (exists $args{shortname});
 	my $self = {
 		shortname => $shortname,
 		perfdata  => [],           # to be added later
@@ -104,14 +102,6 @@
 }
 sub max_state_alt {
     Nagios::Plugin::Functions::max_state_alt(@_);
-}
-
-# Override default shortname accessor to add default
-sub shortname {
-    my $self = shift;
-    $self->{shortname} = shift if @_;
-    return $self->{shortname} || 
-           Nagios::Plugin::Functions::get_shortname();
 }
 
 # top level interface to Nagios::Plugin::Threshold
@@ -254,7 +244,7 @@
    );
 
    # add valid command line options and build them into your usage/help documentation.
-   $p->add_arg(
+   $np->add_arg(
      spec => 'warning|w=s',
      help => '-w, --warning=INTEGER:INTEGER .  See '
        . 'http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT '
@@ -262,7 +252,7 @@
    );
 
    # Parse @ARGV and process standard arguments (e.g. usage, help, version)
-   $p->getopts;
+   $np->getopts;
 
 
    # Exit/return value methods - nagios_exit( CODE, MESSAGE ), 
@@ -517,7 +507,7 @@
 2. explicitly set by calling C<set_thresholds()> before C<check_threshold()>, or,
 
 3. implicitly set by command-line parameters -w, -c, --critical or
-   --warning, if you have run C<$plugin->getopts()>.
+   --warning, if you have run C<< $plugin->getopts() >>.
 
 The return value is ready to pass to C <nagios_exit>, e . g .,
 

Modified: branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Functions.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Functions.pm?rev=56273&op=diff
==============================================================================
--- branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Functions.pm (original)
+++ branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Functions.pm Sat Apr 17 07:13:10 2010
@@ -12,7 +12,7 @@
 use Math::Calc::Units;
 
 # Remember to update Nagios::Plugins as well
-our $VERSION = "0.33";
+our $VERSION = "0.34";
 
 our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT);
 
@@ -54,12 +54,15 @@
 sub _use_die { @_ ? $_use_die = shift : $_use_die };
 
 sub get_shortname {
-    my %arg = @_;
-
-    return $arg{plugin}->shortname if $arg{plugin};
-
-    my $shortname = uc basename($ENV{NAGIOS_PLUGIN} || $0);
-    $shortname =~ s/^CHECK_//;     # Remove any leading CHECK_
+    my $arg = shift;
+
+    my $shortname = undef;
+
+    return $arg->{shortname} if (defined($arg->{shortname}));
+    $shortname = $arg->{plugin} if (defined( $arg->{plugin}));
+
+    $shortname = uc basename($shortname || $ENV{NAGIOS_PLUGIN} || $0);
+    $shortname =~ s/^CHECK_(?:BY_)?//;     # Remove any leading CHECK_[BY_]
     $shortname =~ s/\..*$//;       # Remove any trailing suffix
     return $shortname;
 }
@@ -116,7 +119,8 @@
     # Setup output
     my $output = "$STATUS_TEXT{$code}";
     $output .= " - $message" if defined $message && $message ne '';
-    my $shortname = get_shortname(plugin => $arg->{plugin});
+    my $shortname = ($arg->{plugin} ? $arg->{plugin}->shortname : undef);
+    $shortname ||= get_shortname(); # Should happen only if funnctions are called directly
     $output = "$shortname $output" if $shortname;
     if ($arg->{plugin}) {
         my $plugin = $arg->{plugin};
@@ -173,7 +177,7 @@
 
     # Else just assume $arg1 is the message and hope for the best
     else {
-        return nagios_exit( UNKNOWN, $arg1, $rest );
+        return nagios_exit( UNKNOWN, $arg1, $arg2 );
     }
 }
 

Modified: branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Getopt.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Getopt.pm?rev=56273&op=diff
==============================================================================
--- branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Getopt.pm (original)
+++ branches/upstream/libnagios-plugin-perl/current/lib/Nagios/Plugin/Getopt.pm Sat Apr 17 07:13:10 2010
@@ -38,7 +38,7 @@
     help => "-V, --version\n   Print version information",
   }, {
     spec => 'extra-opts:s@',
-    help => "--extra-opts=[<section>[@<config_file>]]\n   Section and/or config_file from which to load extra options (may repeat)",
+    help => "--extra-opts=[section][\@file]\n   Read options from an ini file. See http://nagiosplugins.org/extra-opts for usage",
   }, {
     spec => 'timeout|t=i',
     help => "-t, --timeout=INTEGER\n   Seconds before plugin times out (default: %s)",

Modified: branches/upstream/libnagios-plugin-perl/current/t/Nagios-Plugin-01.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnagios-plugin-perl/current/t/Nagios-Plugin-01.t?rev=56273&op=diff
==============================================================================
--- branches/upstream/libnagios-plugin-perl/current/t/Nagios-Plugin-01.t (original)
+++ branches/upstream/libnagios-plugin-perl/current/t/Nagios-Plugin-01.t Sat Apr 17 07:13:10 2010
@@ -1,7 +1,7 @@
 # Nagios::Plugin original test cases
 
 use strict;
-use Test::More tests => 13;
+use Test::More tests => 15;
 
 BEGIN { use_ok('Nagios::Plugin') };
 
@@ -22,6 +22,12 @@
 
 $p = Nagios::Plugin->new( shortname => "SIZE", () );
 is($p->shortname, "SIZE", "shortname set correctly on new");
+
+$p = Nagios::Plugin->new( plugin => "check_stuff", () );
+is($p->shortname, "STUFF", "shortname uses plugin name as default");
+
+$p = Nagios::Plugin->new(  shortname => "SIZE", plugin => "check_stuff", () );
+is($p->shortname, "SIZE", "shortname is not overriden by default");
 
 diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE};
 my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" );




More information about the Pkg-perl-cvs-commits mailing list