clean code and add last enhancement
This commit is contained in:
parent
9f2776f1cc
commit
fb647abf22
|
@ -35,18 +35,18 @@ sub custom_metric_output {
|
||||||
my $msg;
|
my $msg;
|
||||||
my $message;
|
my $message;
|
||||||
|
|
||||||
if (defined($config_data->{filters}) && defined($config_data->{filters}->{formatting})) {
|
if (defined($config_data->{selection}->{$self->{result_values}->{instance}}->{formatting})) {
|
||||||
eval {
|
|
||||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
|
||||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
|
||||||
$msg = sprintf("$config_data->{filters}->{formatting}->{printf_msg}", eval "$config_data->{filters}->{formatting}->{printf_var}");
|
|
||||||
};
|
|
||||||
} elsif (defined($config_data->{selection}->{$self->{result_values}->{instance}}->{formatting})) {
|
|
||||||
eval {
|
eval {
|
||||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||||
$msg = sprintf("$config_data->{selection}->{$self->{result_values}->{instance}}->{formatting}->{printf_msg}", eval "$config_data->{selection}->{$self->{result_values}->{instance}}->{formatting}->{printf_var}");
|
$msg = sprintf("$config_data->{selection}->{$self->{result_values}->{instance}}->{formatting}->{printf_msg}", eval "$config_data->{selection}->{$self->{result_values}->{instance}}->{formatting}->{printf_var}");
|
||||||
};
|
};
|
||||||
|
} elsif (defined($config_data->{filters}) && defined($config_data->{filters}->{formatting})) {
|
||||||
|
eval {
|
||||||
|
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||||
|
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||||
|
$msg = sprintf("$config_data->{filters}->{formatting}->{printf_msg}", eval "$config_data->{filters}->{formatting}->{printf_var}");
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
eval {
|
eval {
|
||||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||||
|
@ -108,8 +108,6 @@ sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'global', type => 1, message_multiple => 'Global curves are OK' },
|
|
||||||
{ name => 'metric', type => 1, message_multiple => 'Metric curves are OK' }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
|
@ -155,14 +153,14 @@ sub check_options {
|
||||||
|
|
||||||
$instance_mode = $self;
|
$instance_mode = $self;
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{config_file}) && !defined($self->{option_results}->{json_data}) {
|
if (!defined($self->{option_results}->{config_file}) && !defined($self->{option_results}->{json_data})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please define --config-file or --json-data option");
|
$self->{output}->add_option_msg(short_msg => "Please define --config-file or --json-data option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
if (-f $self->{option_results}->{config_file} && $self->{option_results}->{config_file} eq '') {
|
if (defined($self->{option_results}->{config_file}) && $self->{option_results}->{config_file} ne '') {
|
||||||
$config_data = $self->parse_json_config(config => $self->{option_results}->{config_file});
|
$config_data = $self->parse_json_config(config => $self->{option_results}->{config_file});
|
||||||
} elsif (defined($self->{option_results}->{json_data}) && $self->{option_results}->{json_data} eq '') {
|
} elsif (defined($self->{option_results}->{json_data}) && $self->{option_results}->{json_data} ne '') {
|
||||||
$config_data = $self->parse_json_config(config => $self->{option_results}->{json_data};
|
$config_data = $self->parse_json_config(config => $self->{option_results}->{json_data});
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->add_option_msg(short_msg => "Can't find plugin configuration file / Cannot read from --json-data option");
|
$self->{output}->add_option_msg(short_msg => "Can't find plugin configuration file / Cannot read from --json-data option");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
|
Loading…
Reference in New Issue