WIP: refactoring change_macros method

This commit is contained in:
garnier-quentin 2019-01-14 17:11:41 +01:00
parent 9615d91e6e
commit 3393d1e58f
3 changed files with 12 additions and 22 deletions

View File

@ -235,17 +235,7 @@ sub check_options {
$self->{output}->option_exit();
}
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_state', 'critical_state')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_state', 'critical_state']);
}
sub manage_selection {

View File

@ -425,6 +425,16 @@ sub manage_selection {
#$self->{cache_name} = "choose_name_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
# (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
sub change_macros {
my ($self, %options) = @_;
foreach (@{$options{macros}}) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
1;

View File

@ -125,17 +125,7 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status', 'unknown_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
}
my %map_battery_status = (