From c6ee438b0525b73d36bbcf5e5a9e0d445f69129b Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Fri, 31 Aug 2007 14:34:18 +0000 Subject: 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 --- lib/Nagios/Plugin/Performance.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib') 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; use Nagios::Plugin::Range; our ($VERSION) = $Nagios::Plugin::Functions::VERSION; +sub import { + my ($class, %attr) = @_; + $_ = $attr{use_die} || 0; + Nagios::Plugin::Functions::_use_die($_); +} + sub _parse { my $class = shift; my $string = shift; @@ -112,7 +118,7 @@ performance data. =head1 SYNOPSIS - use Nagios::Plugin::Performance; + use Nagios::Plugin::Performance use_die => 1; # Constructor (also accepts a 'threshold' obj instead of warning/critical) $p = Nagios::Plugin::Performance->new( @@ -162,6 +168,14 @@ parse_perfstring), for turning nagios performance output strings into their components, and a composition interface (via new), for turning components into perfdata strings. +=head1 USE'ING THE MODULE + +If you are using this module for the purposes of parsing perf data, you +will probably want to set use_die => 1 at use time. This forces +&Nagios::Plugin::Functions::nagios_exit to call die() - rather than exit() - +when an error occurs. This is then trappable by an eval. If you don't set use_die, +then an error in these modules will cause your script to exit + =head1 CLASS METHODS =over 4 -- cgit v1.2.3-74-g34f1