WIP: refactoring change_macros method
This commit is contained in:
parent
9615d91e6e
commit
3393d1e58f
|
@ -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 {
|
||||
|
|
|
@ -426,6 +426,16 @@ sub manage_selection {
|
|||
# (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;
|
||||
|
||||
__END__
|
||||
|
|
|
@ -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 = (
|
||||
|
|
Loading…
Reference in New Issue