summaryrefslogtreecommitdiffstats
path: root/lib/Nagios/Plugin/Functions.pm
diff options
context:
space:
mode:
authorGavin Carr <gonzai@users.sourceforge.net>2007-03-16 11:25:15 +0000
committerGavin Carr <gonzai@users.sourceforge.net>2007-03-16 11:25:15 +0000
commitc6cbf050974c8f6642fa1d7bde309710b66cbfa0 (patch)
tree0eb0ea62814b0623fb619c2af3287a585de48c2c /lib/Nagios/Plugin/Functions.pm
parente5109f99c9657a1a8e9fb32b19254a417e2ccd65 (diff)
downloadmonitoring-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.pm18
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;
9use warnings; 9use warnings;
10use File::Basename; 10use File::Basename;
11use Params::Validate qw(validate :types); 11use Params::Validate qw(validate :types);
12use Math::Calc::Units;
12 13
13# Remember to update Nagios::Plugins as well 14# Remember to update Nagios::Plugins as well
14our $VERSION = "0.15"; 15our $VERSION = "0.16";
15 16
16our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); 17our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT);
17 18
18require Exporter; 19require Exporter;
19our @ISA = qw(Exporter); 20our @ISA = qw(Exporter);
20our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); 21our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages));
21our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state); 22our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state convert);
22our %EXPORT_TAGS = ( 23our %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
28use constant OK => 0; 29use 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
157sub 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.