mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
better compat management
This commit is contained in:
parent
5014ee77b9
commit
1f4f421dd1
@ -150,7 +150,7 @@ sub new {
|
|||||||
'filter' => { name => 'filter' },
|
'filter' => { name => 'filter' },
|
||||||
'scope-datacenter:s' => { name => 'scope_datacenter' },
|
'scope-datacenter:s' => { name => 'scope_datacenter' },
|
||||||
'filter-host:s' => { name => 'filter_host' },
|
'filter-host:s' => { name => 'filter_host' },
|
||||||
'units:s' => { name => 'units', default => '%' },
|
'units:s' => { name => 'units', default => '' },
|
||||||
'free' => { name => 'free' }
|
'free' => { name => 'free' }
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,11 +173,6 @@ sub check_options {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$self->SUPER::check_options(%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 {
|
sub custom_usage_calc {
|
||||||
|
@ -705,11 +705,31 @@ sub compat_threshold_counter {
|
|||||||
foreach my $th (@{$options{compat}->{th}}) {
|
foreach my $th (@{$options{compat}->{th}}) {
|
||||||
next if (!defined($options{option_results}->{$_ . '-' . $th->[0]}) || $options{option_results}->{$_ . '-' . $th->[0]} eq '');
|
next if (!defined($options{option_results}->{$_ . '-' . $th->[0]}) || $options{option_results}->{$_ . '-' . $th->[0]} eq '');
|
||||||
|
|
||||||
if (defined($options{compat}->{free})) {
|
my $src_threshold = $options{option_results}->{$_ . '-' . $th->[0]};
|
||||||
$options{option_results}->{$_ . '-' . $th->[1]->{free}} = $options{option_results}->{$_ . '-' . $th->[0]};
|
if (defined($options{compat}->{units}) && $options{compat}->{units} eq '%') {
|
||||||
$options{option_results}->{$_ . '-' . $th->[0]} = undef;
|
$options{option_results}->{$_ . '-' . $th->[0]} = undef;
|
||||||
} elsif (defined($options{compat}->{units}) && $options{compat}->{units} eq '%') {
|
if (defined($options{compat}->{free})) {
|
||||||
$options{option_results}->{$_ . '-' . $th->[1]->{prct}} = $options{option_results}->{$_ . '-' . $th->[0]};
|
$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;
|
$options{option_results}->{$_ . '-' . $th->[0]} = undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'units:s' => { name => 'units', default => '%' },
|
'units:s' => { name => 'units', default => '' },
|
||||||
'free' => { name => 'free' },
|
'free' => { name => 'free' },
|
||||||
'reload-cache-time:s' => { name => 'reload_cache_time', default => 180 },
|
'reload-cache-time:s' => { name => 'reload_cache_time', default => 180 },
|
||||||
'name' => { name => 'use_name' },
|
'name' => { name => 'use_name' },
|
||||||
|
@ -147,7 +147,7 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'units:s' => { name => 'units', default => '%' },
|
'units:s' => { name => 'units', default => '' },
|
||||||
'free' => { name => 'free' },
|
'free' => { name => 'free' },
|
||||||
'swap' => { name => 'check_swap' },
|
'swap' => { name => 'check_swap' },
|
||||||
'patch-redhat' => { name => 'patch_redhat' },
|
'patch-redhat' => { name => 'patch_redhat' },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user