From d8f912e8f5abb1476366cfea6e0fb368a9669ec4 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Mon, 25 Sep 2006 18:40:20 +0000 Subject: Fix Nagios::Plugin->new( shortname => "ANYTHING" ); (Wolfgang Barth) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1481 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/META.yml b/META.yml index 2b98bd5..bd2b6e2 100644 --- a/META.yml +++ b/META.yml @@ -5,6 +5,7 @@ version: 0.13 version_from: lib/Nagios/Plugin/Base.pm installdirs: site requires: + Params::Validate: 0.24 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm index 88c15c5..41bff91 100644 --- a/lib/Nagios/Plugin.pm +++ b/lib/Nagios/Plugin.pm @@ -6,6 +6,7 @@ use 5.008004; use Class::Struct; struct "Nagios::__::Plugin" => { perfdata => '@', + shortname => '$', }; package Nagios::Plugin; @@ -38,9 +39,6 @@ sub all_perfoutput { sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } -my $shortname; -sub shortname { shift; @_ ? $shortname = shift : $shortname } - sub die { my $self = shift; Nagios::Plugin::Base::die(@_, { plugin => $self }); diff --git a/t/Nagios-Plugin.t b/t/Nagios-Plugin.t index 8921dc5..213e514 100644 --- a/t/Nagios-Plugin.t +++ b/t/Nagios-Plugin.t @@ -1,6 +1,6 @@ use strict; -use Test::More tests => 9; +use Test::More tests => 12; BEGIN { use_ok('Nagios::Plugin') }; @@ -13,6 +13,13 @@ my $p = Nagios::Plugin->new; isa_ok( $p, "Nagios::Plugin"); $p->shortname("PAGESIZE"); +is($p->shortname, "PAGESIZE", "shortname set correctly"); + +$p = Nagios::Plugin->new; +ok(! defined $p->shortname, "shortname should be unset on new"); + +$p = Nagios::Plugin->new( shortname => "SIZE" ); +is($p->shortname, "SIZE", "shortname set correctly on new"); diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" ); -- cgit v0.10-9-g596f