From c6cbf050974c8f6642fa1d7bde309710b66cbfa0 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Fri, 16 Mar 2007 11:25:15 +0000 Subject: 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 --- lib/Nagios/Plugin/Functions.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/Nagios/Plugin/Functions.pm') 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; use warnings; use File::Basename; use Params::Validate qw(validate :types); +use Math::Calc::Units; # Remember to update Nagios::Plugins as well -our $VERSION = "0.15"; +our $VERSION = "0.16"; our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); require Exporter; our @ISA = qw(Exporter); our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); -our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state); +our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state convert); our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ], codes => [ @STATUS_CODES ], - functions => [ qw(nagios_exit nagios_die check_messages max_state) ], + functions => [ qw(nagios_exit nagios_die check_messages max_state convert) ], ); use constant OK => 0; @@ -149,6 +150,17 @@ sub nagios_die { sub die { nagios_die(@_); } +# ------------------------------------------------------------------------ +# Utility functions + +# Simple wrapper around Math::Calc::Units::convert +sub convert +{ + my ($value, $from, $to) = @_; + my ($newval) = Math::Calc::Units::convert("$value $from", $to, 'exact'); + return $newval; +} + # ------------------------------------------------------------------------ # check_messages - return a status and/or message based on a set of # message arrays. -- cgit v1.2.3-74-g34f1