diff options
author | Greg Sabino Mullane | 2011-01-24 20:53:32 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2011-01-24 20:53:32 +0000 |
commit | a1b0012d0b9efd1913d46d21c6c20a984a084dca (patch) | |
tree | 5fdd4c9a22a2ec1979ff796b565c18ad4b68d9d1 | |
parent | 13634b5d2f20c31441274755eb72188d434c8bec (diff) |
Have percent option check strip out the % char, for ease in future comparisons.
-rwxr-xr-x | check_postgres.pl | 8 | ||||
-rw-r--r-- | 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: { |