better compat management
This commit is contained in:
parent
58b00c7188
commit
052b2937eb
|
@ -150,7 +150,7 @@ sub new {
|
|||
'filter' => { name => 'filter' },
|
||||
'scope-datacenter:s' => { name => 'scope_datacenter' },
|
||||
'filter-host:s' => { name => 'filter_host' },
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'units:s' => { name => 'units', default => '' },
|
||||
'free' => { name => 'free' }
|
||||
});
|
||||
|
||||
|
@ -173,11 +173,6 @@ sub check_options {
|
|||
);
|
||||
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{units}) || $self->{option_results}->{units} !~ /^(%|B)$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong units option '" . $self->{option_results}->{units} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub custom_usage_calc {
|
||||
|
|
|
@ -705,11 +705,31 @@ sub compat_threshold_counter {
|
|||
foreach my $th (@{$options{compat}->{th}}) {
|
||||
next if (!defined($options{option_results}->{$_ . '-' . $th->[0]}) || $options{option_results}->{$_ . '-' . $th->[0]} eq '');
|
||||
|
||||
if (defined($options{compat}->{free})) {
|
||||
$options{option_results}->{$_ . '-' . $th->[1]->{free}} = $options{option_results}->{$_ . '-' . $th->[0]};
|
||||
my $src_threshold = $options{option_results}->{$_ . '-' . $th->[0]};
|
||||
if (defined($options{compat}->{units}) && $options{compat}->{units} eq '%') {
|
||||
$options{option_results}->{$_ . '-' . $th->[0]} = undef;
|
||||
} elsif (defined($options{compat}->{units}) && $options{compat}->{units} eq '%') {
|
||||
$options{option_results}->{$_ . '-' . $th->[1]->{prct}} = $options{option_results}->{$_ . '-' . $th->[0]};
|
||||
if (defined($options{compat}->{free})) {
|
||||
$options{option_results}->{$_ . '-' . $th->[0]} = undef;
|
||||
my ($status, $result) = centreon::plugins::misc::parse_threshold(threshold => $src_threshold);
|
||||
next if ($status == 0);
|
||||
|
||||
my $tmp = { arobase => $result->{arobase}, infinite_pos => 0, infinite_neg => 0, start => $result->{start}, end => $result->{end} };
|
||||
$tmp->{infinite_neg} = 1 if ($result->{infinite_pos} == 1);
|
||||
$tmp->{infinite_pos} = 1 if ($result->{infinite_neg} == 1);
|
||||
|
||||
if ($result->{start} ne '' && $result->{infinite_neg} == 0) {
|
||||
$tmp->{end} = 100 - $result->{start};
|
||||
}
|
||||
if ($result->{end} ne '' && $result->{infinite_pos} == 0) {
|
||||
$tmp->{start} = 100 - $result->{end};
|
||||
}
|
||||
|
||||
$options{option_results}->{$_ . '-' . $th->[1]->{prct}} = centreon::plugins::misc::get_threshold_litteral(%$tmp);
|
||||
} else {
|
||||
$options{option_results}->{$_ . '-' . $th->[1]->{prct}} = $src_threshold;
|
||||
}
|
||||
} elsif (defined($options{compat}->{free})) {
|
||||
$options{option_results}->{$_ . '-' . $th->[1]->{free}} = $options{option_results}->{$_ . '-' . $th->[0]};
|
||||
$options{option_results}->{$_ . '-' . $th->[0]} = undef;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'units:s' => { name => 'units', default => '' },
|
||||
'free' => { name => 'free' },
|
||||
'reload-cache-time:s' => { name => 'reload_cache_time', default => 180 },
|
||||
'name' => { name => 'use_name' },
|
||||
|
|
|
@ -147,7 +147,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'units:s' => { name => 'units', default => '%' },
|
||||
'units:s' => { name => 'units', default => '' },
|
||||
'free' => { name => 'free' },
|
||||
'swap' => { name => 'check_swap' },
|
||||
'patch-redhat' => { name => 'patch_redhat' },
|
||||
|
|
Loading…
Reference in New Issue