diff options
Diffstat (limited to 'lib/Nagios/Plugin/Range.pm')
-rw-r--r-- | lib/Nagios/Plugin/Range.pm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Nagios/Plugin/Range.pm b/lib/Nagios/Plugin/Range.pm index 3828d1a..32a0639 100644 --- a/lib/Nagios/Plugin/Range.pm +++ b/lib/Nagios/Plugin/Range.pm | |||
@@ -11,7 +11,7 @@ __PACKAGE__->mk_accessors( | |||
11 | qw(start end start_infinity end_infinity alert_on) | 11 | qw(start end start_infinity end_infinity alert_on) |
12 | ); | 12 | ); |
13 | 13 | ||
14 | use Nagios::Plugin::Functions; | 14 | use Nagios::Plugin::Functions qw(:DEFAULT $value_re); |
15 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; | 15 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; |
16 | 16 | ||
17 | use overload | 17 | use overload |
@@ -54,7 +54,7 @@ sub parse_range_string { | |||
54 | 54 | ||
55 | $string =~ s/\s//g; # strip out any whitespace | 55 | $string =~ s/\s//g; # strip out any whitespace |
56 | # check for valid range definition | 56 | # check for valid range definition |
57 | unless ( $string =~ /[\d~]/ && $string =~ m/^\@?(-?[\d.]+|~)?(:(-?[\d.]+)?)?$/ ) { | 57 | unless ( $string =~ /[\d~]/ && $string =~ m/^\@?($value_re|~)?(:($value_re)?)?$/ ) { |
58 | carp "invalid range definition '$string'"; | 58 | carp "invalid range definition '$string'"; |
59 | return undef; | 59 | return undef; |
60 | } | 60 | } |
@@ -66,14 +66,14 @@ sub parse_range_string { | |||
66 | if ($string =~ s/^~//) { # '~:x' | 66 | if ($string =~ s/^~//) { # '~:x' |
67 | $range->start_infinity(1); | 67 | $range->start_infinity(1); |
68 | } | 68 | } |
69 | if ( $string =~ m/^([\d\.-]+)?:/ ) { # '10:' | 69 | if ( $string =~ m/^($value_re)?:/ ) { # '10:' |
70 | my $start = $1; | 70 | my $start = $1; |
71 | $range->_set_range_start($start) if defined $start; | 71 | $range->_set_range_start($start) if defined $start; |
72 | $range->end_infinity(1); # overridden below if there's an end specified | 72 | $range->end_infinity(1); # overridden below if there's an end specified |
73 | $string =~ s/^([-\d\.]+)?://; | 73 | $string =~ s/^($value_re)?://; |
74 | $valid++; | 74 | $valid++; |
75 | } | 75 | } |
76 | if ($string =~ /^([-\d\.]+)$/) { # 'x:10' or '10' | 76 | if ($string =~ /^($value_re)$/) { # 'x:10' or '10' |
77 | $range->_set_range_end($string); | 77 | $range->_set_range_end($string); |
78 | $valid++; | 78 | $valid++; |
79 | } | 79 | } |