From 489df48f9d1891b46ae4be911080ab4667058f2d Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Thu, 8 Feb 2007 15:58:15 +0000 Subject: Fixed warnings when no uom specified for add_perfdata git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1618 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/Changes b/Changes index 88c0fbe..384538b 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl module Nagios::Plugin. +??? ?? + - fixed warnings when no uom specified for add_perfdata + - added max_state function in N::P::Functions + 0.15 19th December 2006 - exposed Getopt and Threshold functionality from top level Nagios::Plugin - exchanged Class::Struct for Class::Accessor diff --git a/lib/Nagios/Plugin/Performance.pm b/lib/Nagios/Plugin/Performance.pm index 6e4cd03..fc1c0bc 100644 --- a/lib/Nagios/Plugin/Performance.pm +++ b/lib/Nagios/Plugin/Performance.pm @@ -22,7 +22,7 @@ struct "Nagios::Plugin::Performance" => { sub perfoutput { my $self = shift; - my $output = $self->label."=".$self->value.$self->uom.";".$self->threshold->warning.";".$self->threshold->critical; + my $output = $self->label."=".$self->value. ($self->uom || "") .";".$self->threshold->warning.";".$self->threshold->critical; return $output; } diff --git a/t/Nagios-Plugin-01.t b/t/Nagios-Plugin-01.t index db12c35..3ada472 100644 --- a/t/Nagios-Plugin-01.t +++ b/t/Nagios-Plugin-01.t @@ -1,7 +1,7 @@ # Nagios::Plugin original test cases use strict; -use Test::More tests => 12; +use Test::More tests => 13; BEGIN { use_ok('Nagios::Plugin') }; @@ -41,6 +41,14 @@ $p->add_perfdata( cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;~:25", "Perfdata correct"); #diag "dumping perfdata: ". Dumper ($p->perfdata); +$p->add_perfdata( + label => "time", + value => "3.52", + threshold => $t, + ); + +is( $p->all_perfoutput, "size=1kB;10:25;~:25 time=3.52;10:25;~:25", "Perfdata correct when no uom specified"); + my $expected = {qw( -1 WARNING 1 WARNING diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t index e0eb2f6..1ae330a 100644 --- a/t/Nagios-Plugin-Performance.t +++ b/t/Nagios-Plugin-Performance.t @@ -80,3 +80,5 @@ cmp_ok( $p[0]->rrdlabel, "eq", "home_a_m", "changing / to _"); cmp_ok( $p[1]->rrdlabel, "eq", "shared_folder_big", "replacing bad characters"); cmp_ok( $p[2]->rrdlabel, "eq", "1234567890123456789", "shortening rrd label"); + +# add_perfdata tests in t/Nagios-Plugin-01.t -- cgit v0.10-9-g596f