diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-09-25 18:40:20 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-09-25 18:40:20 +0000 |
commit | d8f912e8f5abb1476366cfea6e0fb368a9669ec4 (patch) | |
tree | dfe890aa42474694cbc2d20532c33b62595294c4 | |
parent | e0486d70c246c59d28a8ffdc042e9b8010978d2d (diff) | |
download | monitoring-plugin-perl-d8f912e8f5abb1476366cfea6e0fb368a9669ec4.tar.gz |
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
-rw-r--r-- | META.yml | 1 | ||||
-rw-r--r-- | lib/Nagios/Plugin.pm | 4 | ||||
-rw-r--r-- | t/Nagios-Plugin.t | 9 |
3 files changed, 10 insertions, 4 deletions
@@ -5,6 +5,7 @@ version: 0.13 | |||
5 | version_from: lib/Nagios/Plugin/Base.pm | 5 | version_from: lib/Nagios/Plugin/Base.pm |
6 | installdirs: site | 6 | installdirs: site |
7 | requires: | 7 | requires: |
8 | Params::Validate: 0.24 | ||
8 | 9 | ||
9 | distribution_type: module | 10 | distribution_type: module |
10 | generated_by: ExtUtils::MakeMaker version 6.17 | 11 | 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; | |||
6 | use Class::Struct; | 6 | use Class::Struct; |
7 | struct "Nagios::__::Plugin" => { | 7 | struct "Nagios::__::Plugin" => { |
8 | perfdata => '@', | 8 | perfdata => '@', |
9 | shortname => '$', | ||
9 | }; | 10 | }; |
10 | 11 | ||
11 | package Nagios::Plugin; | 12 | package Nagios::Plugin; |
@@ -38,9 +39,6 @@ sub all_perfoutput { | |||
38 | 39 | ||
39 | sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } | 40 | sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } |
40 | 41 | ||
41 | my $shortname; | ||
42 | sub shortname { shift; @_ ? $shortname = shift : $shortname } | ||
43 | |||
44 | sub die { | 42 | sub die { |
45 | my $self = shift; | 43 | my $self = shift; |
46 | Nagios::Plugin::Base::die(@_, { plugin => $self }); | 44 | 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 @@ | |||
1 | 1 | ||
2 | use strict; | 2 | use strict; |
3 | use Test::More tests => 9; | 3 | use Test::More tests => 12; |
4 | 4 | ||
5 | BEGIN { use_ok('Nagios::Plugin') }; | 5 | BEGIN { use_ok('Nagios::Plugin') }; |
6 | 6 | ||
@@ -13,6 +13,13 @@ my $p = Nagios::Plugin->new; | |||
13 | isa_ok( $p, "Nagios::Plugin"); | 13 | isa_ok( $p, "Nagios::Plugin"); |
14 | 14 | ||
15 | $p->shortname("PAGESIZE"); | 15 | $p->shortname("PAGESIZE"); |
16 | is($p->shortname, "PAGESIZE", "shortname set correctly"); | ||
17 | |||
18 | $p = Nagios::Plugin->new; | ||
19 | ok(! defined $p->shortname, "shortname should be unset on new"); | ||
20 | |||
21 | $p = Nagios::Plugin->new( shortname => "SIZE" ); | ||
22 | is($p->shortname, "SIZE", "shortname set correctly on new"); | ||
16 | 23 | ||
17 | diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; | 24 | diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; |
18 | my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" ); | 25 | my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" ); |