From a1b0012d0b9efd1913d46d21c6c20a984a084dca Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Mon, 24 Jan 2011 15:53:32 -0500 Subject: [PATCH] Have percent option check strip out the % char, for ease in future comparisons. --- check_postgres.pl | 8 ++++---- t/01_validate_range.t | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index 12cdecfc1..2f9e204fa 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -2383,17 +2383,17 @@ sub validate_range { } elsif ('percent' eq $type) { if (length $critical) { - if ($critical !~ /^\d+\%$/) { + if ($critical !~ /^(\d+)\%$/) { ndie msg('range-badpercent', 'critical'); } + $critical = $1; } if (length $warning) { - if ($warning !~ /^\d+\%$/) { + if ($warning !~ /^(\d+)\%$/) { ndie msg('range-badpercent', 'warning'); } + $warning = $1; } - $warning = $warning if length $warning; - $critical = $critical if length $warning; } elsif ('size or percent' eq $type) { if (length $critical) { diff --git a/t/01_validate_range.t b/t/01_validate_range.t index 2507c671f..a41bf34fa 100644 --- a/t/01_validate_range.t +++ b/t/01_validate_range.t @@ -214,8 +214,8 @@ PERCENT: { warning => '5%', ); my ($w, $c) = check_postgres::validate_range({ type => 'percent' }); - is $w, '5%', 'Should have warning == 5%'; - is $c, '90%', 'Should have critical == 90%'; + is $w, '5', 'Should have warning == 5%'; + is $c, '90', 'Should have critical == 90%'; } SIZEORPERCENT: { -- 2.30.2