diff options
author | Gavin Carr <gonzai@users.sourceforge.net> | 2007-03-16 11:25:15 +0000 |
---|---|---|
committer | Gavin Carr <gonzai@users.sourceforge.net> | 2007-03-16 11:25:15 +0000 |
commit | c6cbf050974c8f6642fa1d7bde309710b66cbfa0 (patch) | |
tree | 0eb0ea62814b0623fb619c2af3287a585de48c2c /lib/Nagios/Plugin/Functions.pm | |
parent | e5109f99c9657a1a8e9fb32b19254a417e2ccd65 (diff) | |
download | monitoring-plugin-perl-c6cbf050974c8f6642fa1d7bde309710b66cbfa0.tar.gz |
Cleanups, mostly to N::P::Range/Threshold/Performance.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1641 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/Nagios/Plugin/Functions.pm')
-rw-r--r-- | lib/Nagios/Plugin/Functions.pm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm index 513501b..526dbed 100644 --- a/lib/Nagios/Plugin/Functions.pm +++ b/lib/Nagios/Plugin/Functions.pm | |||
@@ -9,20 +9,21 @@ 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(validate :types); |
12 | use Math::Calc::Units; | ||
12 | 13 | ||
13 | # Remember to update Nagios::Plugins as well | 14 | # Remember to update Nagios::Plugins as well |
14 | our $VERSION = "0.15"; | 15 | our $VERSION = "0.16"; |
15 | 16 | ||
16 | our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); | 17 | our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); |
17 | 18 | ||
18 | require Exporter; | 19 | require Exporter; |
19 | our @ISA = qw(Exporter); | 20 | our @ISA = qw(Exporter); |
20 | our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); | 21 | our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); |
21 | our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state); | 22 | our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state convert); |
22 | our %EXPORT_TAGS = ( | 23 | our %EXPORT_TAGS = ( |
23 | all => [ @EXPORT, @EXPORT_OK ], | 24 | all => [ @EXPORT, @EXPORT_OK ], |
24 | codes => [ @STATUS_CODES ], | 25 | codes => [ @STATUS_CODES ], |
25 | functions => [ qw(nagios_exit nagios_die check_messages max_state) ], | 26 | functions => [ qw(nagios_exit nagios_die check_messages max_state convert) ], |
26 | ); | 27 | ); |
27 | 28 | ||
28 | use constant OK => 0; | 29 | use constant OK => 0; |
@@ -150,6 +151,17 @@ sub die { nagios_die(@_); } | |||
150 | 151 | ||
151 | 152 | ||
152 | # ------------------------------------------------------------------------ | 153 | # ------------------------------------------------------------------------ |
154 | # Utility functions | ||
155 | |||
156 | # Simple wrapper around Math::Calc::Units::convert | ||
157 | sub convert | ||
158 | { | ||
159 | my ($value, $from, $to) = @_; | ||
160 | my ($newval) = Math::Calc::Units::convert("$value $from", $to, 'exact'); | ||
161 | return $newval; | ||
162 | } | ||
163 | |||
164 | # ------------------------------------------------------------------------ | ||
153 | # check_messages - return a status and/or message based on a set of | 165 | # check_messages - return a status and/or message based on a set of |
154 | # message arrays. | 166 | # message arrays. |
155 | # Returns a nagios status code in scalar context. | 167 | # Returns a nagios status code in scalar context. |