Refs #6339 - Add threshold overload

This commit is contained in:
Mathieu Cinquin 2015-04-16 10:32:08 +02:00
parent 74bfefabb8
commit 3b0d26708c
1 changed files with 31 additions and 8 deletions

View File

@ -72,6 +72,7 @@ sub new {
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => '3' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
return $self;
@ -89,6 +90,22 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
$self->{output}->option_exit();
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong treshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $status, $filter) = ($1, $2, $3);
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong treshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
}
sub get_severity {
@ -192,6 +209,12 @@ Specify username for API authentification
Specify password for API authentification
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='indices,CRITICAL,^(?!(on)$)'
=item B<--timeout>
Threshold for HTTP timeout (Default: 3)