mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 16:45:04 +02:00
mode sql-string - option --printf-value can use new format variable name (#4631)
Co-authored-by: Lucie Dubrunfaut <123162035+lucie-dubrunfaut@users.noreply.github.com>
This commit is contained in:
parent
6f48d96cd3
commit
7402f466cd
@ -53,7 +53,7 @@ sub custom_string_output {
|
|||||||
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("$self->{instance_mode}->{option_results}->{printf_format}", eval $self->{instance_mode}->{option_results}->{printf_value});
|
$msg = sprintf("$self->{instance_mode}->{option_results}->{printf_format}", $self->{result_values}->{ $self->{instance_mode}->{printf_value} });
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
$msg = sprintf("'%s'", $self->{result_values}->{value_field});
|
$msg = sprintf("'%s'", $self->{result_values}->{value_field});
|
||||||
@ -62,6 +62,7 @@ sub custom_string_output {
|
|||||||
if (defined($message)) {
|
if (defined($message)) {
|
||||||
$self->{output}->output_add(long_msg => 'output value issue: ' . $message);
|
$self->{output}->output_add(long_msg => 'output value issue: ' . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +92,16 @@ sub check_options {
|
|||||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--sql-statement' option.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify '--sql-statement' option.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{printf_value} = 'value_field';
|
||||||
|
if (defined($self->{option_results}->{printf_value}) && $self->{option_results}->{printf_value} ne '') {
|
||||||
|
$self->{printf_value} = $1
|
||||||
|
if ($self->{option_results}->{printf_value} =~ /\$self->{result_values}->{(value_field|key_field)}/);
|
||||||
|
$self->{printf_value} = $1
|
||||||
|
if ($self->{option_results}->{printf_value} =~ /\%{(value_field|key_field)}/);
|
||||||
|
$self->{printf_value} = $1
|
||||||
|
if ($self->{option_results}->{printf_value} =~ /\%\((value_field|key_field)\)/);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
@ -155,12 +166,12 @@ Value column (must be one of the selected field). MANDATORY
|
|||||||
|
|
||||||
=item B<--printf-format>
|
=item B<--printf-format>
|
||||||
|
|
||||||
Specify a custom output message relying on printf formatting
|
Specify a custom output message relying on printf formatting. If this option is set --printf-value is mandatory.
|
||||||
|
|
||||||
=item B<--printf-value>
|
=item B<--printf-value>
|
||||||
|
|
||||||
Specify scalar used to replace in printf
|
Specify scalar used to replace in printf. If this option is set --printf-format is mandatory.
|
||||||
(Can be: $self->{result_values}->{key_field}, $self->{result_values}->{value_field})
|
(Can be: %{key_field}, %{value_field})
|
||||||
|
|
||||||
=item B<--warning-string>
|
=item B<--warning-string>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user