Changeset e5c7025c2dfd4fd6f3a70759b51e8ab7a1efd1b2

Show
Ignore:
Timestamp:
04/25/11 21:02:47 (4 years ago)
Author:
Mark Harrison <mark@mivok.net>
git-committer:
Mark Harrison <mark@mivok.net> 1303765367 -0400
git-parent:

[cbdafc7828c365598882711905b828493f504a59]

git-author:
Mark Harrison <mark@mivok.net> 1303765367 -0400
Message:

Fix for values of 0 in numeric thresholds

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • resources/check_resmon_metric

    rcbdafc7 re5c7025  
    188188 
    189189my ($port, $host, $module, $check, $age, $warning, $critical, $equals, $regex, 
    190     $metric, $url, $allow_absent) = (81,"","","",0, "", "", "", "", 0); 
     190    $metric, $url, $allow_absent) = (81, undef, undef, undef, 0, undef, undef, 
     191    undef, undef, 0); 
    191192 
    192193sub help { 
     
    217218    my ($value, $warning, $critical) = @_; 
    218219    my ($state, $message, $warnmessage, $critmessage) = (0,"","",""); 
    219     if ($critical) { 
     220    if (defined $critical) { 
    220221        ($state, $critmessage) = check_single_threshold($value, $critical); 
    221222        if (!$state) { 
     
    224225        $message = $critmessage; 
    225226    } 
    226     if ($warning) { 
     227    if (defined $warning) { 
    227228        ($state, $warnmessage) = check_single_threshold($value, $warning); 
    228229        if (!$state) { 
     
    242243    my ($inclusive, $start, $end) = ( 
    243244        $threshold =~ /(\@?)(?:(-?[0-9.]+|~):)?(-?[0-9.]+|~)?/); 
    244     $start ||= 0; 
    245     $end ||= ""; 
     245    $start = "0" unless defined $start; 
     246    $end = "" unless defined $end; 
     247 
    246248    my $message; 
    247249    my $goodmessage; 
     
    294296    "a|allowabsent" => \$allow_absent); 
    295297 
    296 unless ($host && $module && $check) { 
     298unless (defined $host && defined $module && defined $check) { 
    297299    short_help(); 
    298300} 
    299301 
    300 if (($warning || $critical || $equals ) && $regex) { 
     302if ((defined $warning || defined $critical || defined $equals ) && 
     303    defined $regex) { 
    301304    print "Cannot specify both numeric thresholds and a string based match\n"; 
    302305    exit $ERRORS{'UNKNOWN'}; 
    303306} 
    304307 
    305 if (($warning || $critical ) && $equals) { 
     308if ((defined $warning || defined $critical ) && defined $equals) { 
    306309    print "Cannot specify thresholds and equals\n"; 
    307310    exit $ERRORS{'UNKNOWN'}; 
     
    358361    # you are too. 
    359362    die "Numeric threshold specified for a non-numeric metric" 
    360         if (($warning || $critical) && $type !~ /[0IlLni]/); 
    361  
    362  
    363     if ($equals) { 
     363        if ((defined $warning || defined $critical) && $type !~ /[0IlLni]/); 
     364 
     365 
     366    if (defined $equals) { 
    364367        if ($value eq $equals) { 
    365368            $state = "OK"; 
     
    370373    } 
    371374  
    372     if ($regex) { 
     375    if (defined $regex) { 
    373376        if ($value =~ /$regex/) { 
    374377            $state = "OK"; 
     
    379382    } 
    380383 
    381     if ($warning || $critical) { 
     384    if (defined $warning || defined $critical) { 
    382385        my $message; 
    383386        ($state, $message) = check_threshold($value, $warning, $critical);