diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-03-10 01:54:06 -0500 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-03-12 08:09:11 -0500 |
commit | c128d293b015291c5e45637d9e3d5b1e1fb36c12 (patch) | |
tree | 4b406d48f9d21b59a2aa4600b6d52ac11b7da4fd /lib/Nagios/Plugin.pm | |
parent | 58a1764446e5a1a30db360ee7a69555d7f2e8f1a (diff) | |
download | monitoring-plugin-perl-c128d293b015291c5e45637d9e3d5b1e1fb36c12.tar.gz |
shortname enhancement
This patch makes shortname use the defined plugin's name if set,
otherwise the normal method should prevail. To do so I had to
generate shortname during np initialization instead of at use time.
Diffstat (limited to 'lib/Nagios/Plugin.pm')
-rw-r--r-- | lib/Nagios/Plugin.pm | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm index 697005a..82bbfcb 100644 --- a/lib/Nagios/Plugin.pm +++ b/lib/Nagios/Plugin.pm | |||
@@ -11,6 +11,7 @@ use Carp; | |||
11 | use base qw(Class::Accessor::Fast); | 11 | use base qw(Class::Accessor::Fast); |
12 | 12 | ||
13 | Nagios::Plugin->mk_accessors(qw( | 13 | Nagios::Plugin->mk_accessors(qw( |
14 | shortname | ||
14 | perfdata | 15 | perfdata |
15 | messages | 16 | messages |
16 | opts | 17 | opts |
@@ -45,11 +46,8 @@ sub new { | |||
45 | }, | 46 | }, |
46 | ); | 47 | ); |
47 | 48 | ||
48 | my $shortname = undef; | 49 | my $shortname = Nagios::Plugin::Functions::get_shortname(\%args); |
49 | if (exists $args{shortname}) { | 50 | delete $args{shortname} if (exists $args{shortname}); |
50 | $shortname = $args{shortname}; | ||
51 | delete $args{shortname}; | ||
52 | } | ||
53 | my $self = { | 51 | my $self = { |
54 | shortname => $shortname, | 52 | shortname => $shortname, |
55 | perfdata => [], # to be added later | 53 | perfdata => [], # to be added later |
@@ -106,14 +104,6 @@ sub max_state_alt { | |||
106 | Nagios::Plugin::Functions::max_state_alt(@_); | 104 | Nagios::Plugin::Functions::max_state_alt(@_); |
107 | } | 105 | } |
108 | 106 | ||
109 | # Override default shortname accessor to add default | ||
110 | sub shortname { | ||
111 | my $self = shift; | ||
112 | $self->{shortname} = shift if @_; | ||
113 | return $self->{shortname} || | ||
114 | Nagios::Plugin::Functions::get_shortname(); | ||
115 | } | ||
116 | |||
117 | # top level interface to Nagios::Plugin::Threshold | 107 | # top level interface to Nagios::Plugin::Threshold |
118 | sub check_threshold { | 108 | sub check_threshold { |
119 | my $self = shift; | 109 | my $self = shift; |