diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-09-24 18:45:59 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-09-24 18:45:59 +0000 |
commit | 6625e6a0d2a4cec99339b8b526035592dcd4418c (patch) | |
tree | 85971687f4bfef6a7f30595522f2454c73f4b2af /lib/Nagios/Plugin/Functions.pm | |
parent | 7fb5ed0f0a95ce5817e0b0f7c3bba91968393d49 (diff) | |
download | monitoring-plugin-perl-6625e6a0d2a4cec99339b8b526035592dcd4418c.tar.gz |
Help, usage and version output go to stdout now, rather than stderr
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1795 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/Nagios/Plugin/Functions.pm')
-rw-r--r-- | lib/Nagios/Plugin/Functions.pm | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm index e6baca9..87f0ccd 100644 --- a/lib/Nagios/Plugin/Functions.pm +++ b/lib/Nagios/Plugin/Functions.pm | |||
@@ -8,7 +8,7 @@ use 5.006; | |||
8 | use strict; | 8 | use strict; |
9 | use warnings; | 9 | use warnings; |
10 | use File::Basename; | 10 | use File::Basename; |
11 | use Params::Validate qw(validate :types); | 11 | use Params::Validate qw(:types validate); |
12 | use Math::Calc::Units; | 12 | use Math::Calc::Units; |
13 | 13 | ||
14 | # Remember to update Nagios::Plugins as well | 14 | # Remember to update Nagios::Plugins as well |
@@ -119,14 +119,24 @@ sub nagios_exit { | |||
119 | return Nagios::Plugin::ExitResult->new($code, $output); | 119 | return Nagios::Plugin::ExitResult->new($code, $output); |
120 | } | 120 | } |
121 | 121 | ||
122 | # Print output and exit; die if called via nagios_die and flag set | 122 | _nagios_exit($code, $output); |
123 | if($_use_die && (caller(1))[3] =~ m/die/) { | 123 | } |
124 | $!=$code; | 124 | |
125 | die($output); | 125 | sub _nagios_exit { |
126 | } else { | 126 | my ($code, $output) = @_; |
127 | print $output; | 127 | # Print output and exit; die if flag set and called via a die in stack backtrace |
128 | exit $code; | 128 | if ($_use_die) { |
129 | for (my $i = 0;; $i++) { | ||
130 | @_ = caller($i); | ||
131 | last unless @_; | ||
132 | if ($_[3] =~ m/die/) { | ||
133 | $! = $code; | ||
134 | die($output); | ||
135 | } | ||
136 | } | ||
129 | } | 137 | } |
138 | print $output; | ||
139 | exit $code; | ||
130 | } | 140 | } |
131 | 141 | ||
132 | # nagios_die( $message, [ $code ]) OR nagios_die( $code, $message ) | 142 | # nagios_die( $message, [ $code ]) OR nagios_die( $code, $message ) |