diff options
Diffstat (limited to 'lib/Nagios/Plugin.pm')
-rw-r--r-- | lib/Nagios/Plugin.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm index 5debdbc..29b79b9 100644 --- a/lib/Nagios/Plugin.pm +++ b/lib/Nagios/Plugin.pm | |||
@@ -12,8 +12,6 @@ struct "Nagios::__::Plugin" => { | |||
12 | package Nagios::Plugin; | 12 | package Nagios::Plugin; |
13 | 13 | ||
14 | use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES); | 14 | use Nagios::Plugin::Functions qw(:codes %ERRORS %STATUS_TEXT @STATUS_CODES); |
15 | use Nagios::Plugin::Performance; | ||
16 | use Nagios::Plugin::Threshold; | ||
17 | 15 | ||
18 | use strict; | 16 | use strict; |
19 | use warnings; | 17 | use warnings; |
@@ -29,6 +27,7 @@ our $VERSION = $Nagios::Plugin::Functions::VERSION; | |||
29 | 27 | ||
30 | sub add_perfdata { | 28 | sub add_perfdata { |
31 | my ($self, %args) = @_; | 29 | my ($self, %args) = @_; |
30 | require Nagios::Plugin::Performance; | ||
32 | my $perf = Nagios::Plugin::Performance->new(%args); | 31 | my $perf = Nagios::Plugin::Performance->new(%args); |
33 | push @{$self->perfdata}, $perf; | 32 | push @{$self->perfdata}, $perf; |
34 | } | 33 | } |
@@ -37,7 +36,11 @@ sub all_perfoutput { | |||
37 | return join(" ", map {$_->perfoutput} (@{$self->perfdata})); | 36 | return join(" ", map {$_->perfoutput} (@{$self->perfdata})); |
38 | } | 37 | } |
39 | 38 | ||
40 | sub set_thresholds { shift; Nagios::Plugin::Threshold->set_thresholds(@_); } | 39 | sub set_thresholds { |
40 | shift; | ||
41 | require Nagios::Plugin::Threshold; | ||
42 | Nagios::Plugin::Threshold->set_thresholds(@_); | ||
43 | } | ||
41 | 44 | ||
42 | # NP::Functions wrappers | 45 | # NP::Functions wrappers |
43 | sub nagios_exit { | 46 | sub nagios_exit { |
@@ -52,6 +55,13 @@ sub die { | |||
52 | my $self = shift; | 55 | my $self = shift; |
53 | Nagios::Plugin::Functions::nagios_die(@_, { plugin => $self }); | 56 | Nagios::Plugin::Functions::nagios_die(@_, { plugin => $self }); |
54 | } | 57 | } |
58 | # Override default shortname accessor to add default | ||
59 | sub shortname { | ||
60 | my $self = shift; | ||
61 | $self->{'Nagios::__::Plugin::shortname'} = shift if @_; | ||
62 | return $self->{'Nagios::__::Plugin::shortname'} || | ||
63 | Nagios::Plugin::Functions::get_shortname(); | ||
64 | } | ||
55 | 65 | ||
56 | # ------------------------------------------------------------------------- | 66 | # ------------------------------------------------------------------------- |
57 | # NP::Functions::check_messages helpers and wrappers | 67 | # NP::Functions::check_messages helpers and wrappers |