WIP: refactoring change_macros method
This commit is contained in:
parent
eb5821ac69
commit
1902890ae2
|
@ -235,17 +235,7 @@ sub check_options {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->change_macros();
|
$self->change_macros(macros => ['warning_state', 'critical_state']);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
|
|
|
@ -425,6 +425,16 @@ sub manage_selection {
|
||||||
#$self->{cache_name} = "choose_name_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
#$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'));
|
# (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;
|
1;
|
||||||
|
|
||||||
|
|
|
@ -125,17 +125,7 @@ sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::check_options(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
$self->change_macros();
|
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my %map_battery_status = (
|
my %map_battery_status = (
|
||||||
|
|
Loading…
Reference in New Issue