Ticket #828: LimitsOld.pm.patch
| File LimitsOld.pm.patch, 2.5 kB (added by janl, 2 years ago) |
|---|
-
LimitsOld.pm
old new 341 341 : "Value is unknown." 342 342 )); 343 343 344 if ( !defined $onfield 345 or !defined $onfield->{"state"} 346 or $onfield->{"state"} ne "unknown") { 344 # Maintain a countdown of consecutive UNKNOWN values starting 345 # at the value of "unknown_limit". 346 my $notify_countdown = $unknown_limit; 347 if (defined $onfield and defined $onfield->{"state"} and 348 $onfield->{"state"} eq "unknown" and 349 defined $onfield->{"notify_countdown"}) { 350 $notify_countdown = $onfield->{"notify_countdown"}; 351 } 352 353 # Check if we've seen at least $unknown_limit 354 # consecutive UNKNOWN values before creating a state 355 # change. 356 if ($notify_countdown == 1) { 347 357 $hash->{'state_changed'} = 1; 348 358 } 359 360 $notify_countdown = ($notify_countdown > 0 361 ? $notify_countdown - 1 362 : 0); 363 munin_set_var_loc( 364 \%notes, 365 [@$fpath, "notify_countdown"], 366 $notify_countdown); 349 367 } 350 368 elsif ((defined($crit->[0]) and $value < $crit->[0]) 351 369 or (defined($crit->[1]) and $value > $crit->[1])) { … … 404 422 elsif (defined $onfield and defined $onfield->{"state"} or $force) { 405 423 munin_set_var_loc(\%notes, [@$fpath, "state"], "ok"); 406 424 munin_set_var_loc(\%notes, [@$fpath, "ok"], "OK"); 407 $hash->{'state_changed'} = 1;425 $hash->{'state_changed'} = 1; 408 426 } 409 427 } 410 428 generate_service_message($hash); … … 451 469 DEBUG "[DEBUG] processing warning: $name -> $warning[0] : $warning[1]"; 452 470 } 453 471 454 # The merge of the unknown_limit implementation was somewhat botched. Not tested. - janl455 472 if ($unknown_limit =~ /^\s*(\d+)\s*$/) { 456 $unknown_limit = $1 if defined $1; 457 DEBUG "[DEBUG] processing unknown_limit: $name -> $unknown_limit"; 473 $unknown_limit = $1 if defined $1; 474 if (defined $unknown_limit) { 475 if ($unknown_limit < 1) { 476 # Zero and negative numbers are not valid. 477 $unknown_limit = 1; 478 } 479 } 480 DEBUG "[DEBUG] processing unknown_limit: $name -> $unknown_limit"; 458 481 } 459 482 460 483 return (\@warning, \@critical, $unknown_limit);
