From c128d293b015291c5e45637d9e3d5b1e1fb36c12 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Wed, 10 Mar 2010 01:54:06 -0500 Subject: 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. --- lib/Nagios/Plugin.pm | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'lib/Nagios/Plugin.pm') 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; use base qw(Class::Accessor::Fast); Nagios::Plugin->mk_accessors(qw( + shortname perfdata messages opts @@ -45,11 +46,8 @@ sub new { }, ); - 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 @@ -106,14 +104,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 sub check_threshold { my $self = shift; -- cgit v1.2.3-74-g34f1