diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-08-31 14:34:18 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-08-31 14:34:18 +0000 |
commit | c6ee438b0525b73d36bbcf5e5a9e0d445f69129b (patch) | |
tree | efc1ed1556e6a4be7f6f3cd83f0ce24217dcfbbe /lib/Nagios/Plugin/Performance.pm | |
parent | 95dba9c4213c2e7e8f4b572efd873c1979406221 (diff) | |
download | monitoring-plugin-perl-c6ee438b0525b73d36bbcf5e5a9e0d445f69129b.tar.gz |
Convenience function to set use_die on use of N::P::Performance
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1773 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/Nagios/Plugin/Performance.pm')
-rw-r--r-- | lib/Nagios/Plugin/Performance.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Nagios/Plugin/Performance.pm b/lib/Nagios/Plugin/Performance.pm index 63727c0..7ce5fa1 100644 --- a/lib/Nagios/Plugin/Performance.pm +++ b/lib/Nagios/Plugin/Performance.pm | |||
@@ -16,6 +16,12 @@ use Nagios::Plugin::Threshold; | |||
16 | use Nagios::Plugin::Range; | 16 | use Nagios::Plugin::Range; |
17 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; | 17 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; |
18 | 18 | ||
19 | sub import { | ||
20 | my ($class, %attr) = @_; | ||
21 | $_ = $attr{use_die} || 0; | ||
22 | Nagios::Plugin::Functions::_use_die($_); | ||
23 | } | ||
24 | |||
19 | sub _parse { | 25 | sub _parse { |
20 | my $class = shift; | 26 | my $class = shift; |
21 | my $string = shift; | 27 | my $string = shift; |
@@ -112,7 +118,7 @@ performance data. | |||
112 | 118 | ||
113 | =head1 SYNOPSIS | 119 | =head1 SYNOPSIS |
114 | 120 | ||
115 | use Nagios::Plugin::Performance; | 121 | use Nagios::Plugin::Performance use_die => 1; |
116 | 122 | ||
117 | # Constructor (also accepts a 'threshold' obj instead of warning/critical) | 123 | # Constructor (also accepts a 'threshold' obj instead of warning/critical) |
118 | $p = Nagios::Plugin::Performance->new( | 124 | $p = Nagios::Plugin::Performance->new( |
@@ -162,6 +168,14 @@ parse_perfstring), for turning nagios performance output strings into | |||
162 | their components, and a composition interface (via new), for turning | 168 | their components, and a composition interface (via new), for turning |
163 | components into perfdata strings. | 169 | components into perfdata strings. |
164 | 170 | ||
171 | =head1 USE'ING THE MODULE | ||
172 | |||
173 | If you are using this module for the purposes of parsing perf data, you | ||
174 | will probably want to set use_die => 1 at use time. This forces | ||
175 | &Nagios::Plugin::Functions::nagios_exit to call die() - rather than exit() - | ||
176 | when an error occurs. This is then trappable by an eval. If you don't set use_die, | ||
177 | then an error in these modules will cause your script to exit | ||
178 | |||
165 | =head1 CLASS METHODS | 179 | =head1 CLASS METHODS |
166 | 180 | ||
167 | =over 4 | 181 | =over 4 |