Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add single quote in change-perfdata help #4803

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions src/centreon/plugins/output.pm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ sub add_option_msg {
sub set_ignore_label {
my ($self, %options) = @_;

$self->{option_results}->{output_ignore_label} = 1;
$self->{option_results}->{output_ignore_label} = 1;
}

sub set_status {
Expand Down Expand Up @@ -208,7 +208,7 @@ sub output_add {
} else {
$self->{global_short_concat_outputs}->{uc($options->{severity})} = $options->{short_msg};
}

push @{$self->{global_short_outputs}->{uc($options->{severity})}}, $options->{short_msg};
$self->set_status(exit_litteral => $options->{severity});
}
Expand All @@ -231,7 +231,7 @@ sub perfdata_add {
$perfdata->{$_} = $options{$_};
}

if ((defined($self->{option_results}->{use_new_perfdata}) || defined($options{force_new_perfdata})) &&
if ((defined($self->{option_results}->{use_new_perfdata}) || defined($options{force_new_perfdata})) &&
defined($options{nlabel})) {
$perfdata->{label} = $options{nlabel};
}
Expand Down Expand Up @@ -293,7 +293,7 @@ sub output_json {
outputs => [],
perfdatas => []
}
};
};

foreach my $code_litteral (keys %{$self->{global_short_outputs}}) {
foreach (@{$self->{global_short_outputs}->{$code_litteral}}) {
Expand Down Expand Up @@ -343,7 +343,7 @@ sub output_xml {
my ($self, %options) = @_;
my $force_ignore_perfdata = (defined($options{force_ignore_perfdata}) && $options{force_ignore_perfdata} == 1) ? 1 : 0;
my $force_long_output = (defined($options{force_long_output}) && $options{force_long_output} == 1) ? 1 : 0;
my ($child_plugin_name, $child_plugin_mode, $child_plugin_exit, $child_plugin_output, $child_plugin_perfdata);
my ($child_plugin_name, $child_plugin_mode, $child_plugin_exit, $child_plugin_output, $child_plugin_perfdata);

my $root = $self->{xml_output}->createElement('plugin');
$self->{xml_output}->setDocumentElement($root);
Expand Down Expand Up @@ -411,7 +411,7 @@ sub output_xml {
foreach my $perf (@{$self->{perfdatas}}) {
next if ($self->filter_perfdata(perf => $perf));
$self->range_perfdata(ranges => [\$perf->{warning}, \$perf->{critical}]);

my ($child_perfdata);
$child_perfdata = $self->{xml_output}->createElement('perfdata');
$child_plugin_perfdata->addChild($child_perfdata);
Expand Down Expand Up @@ -593,8 +593,8 @@ sub display {
$self->create_xml_document();
if ($self->{is_output_xml}) {
$self->output_xml(
exit_litteral => $self->get_litteral_status(),
nolabel => $nolabel,
exit_litteral => $self->get_litteral_status(),
nolabel => $nolabel,
force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output
);
return ;
Expand All @@ -603,7 +603,7 @@ sub display {
$self->create_json_document();
if ($self->{is_output_json}) {
$self->output_json(
exit_litteral => $self->get_litteral_status(),
exit_litteral => $self->get_litteral_status(),
nolabel => $nolabel,
force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output
);
Expand All @@ -615,7 +615,7 @@ sub display {
}

$self->output_txt(
exit_litteral => $self->get_litteral_status(),
exit_litteral => $self->get_litteral_status(),
nolabel => $nolabel,
force_ignore_perfdata => $force_ignore_perfdata, force_long_output => $force_long_output
);
Expand All @@ -642,7 +642,7 @@ sub die_exit {
$self->output_json(exit_litteral => $exit_litteral, nolabel => $nolabel, force_ignore_perfdata => 1);
$self->exit(exit_litteral => $exit_litteral);
}
}
}

$self->output_txt(exit_litteral => $exit_litteral, nolabel => $nolabel, force_ignore_perfdata => 1);
$self->exit(exit_litteral => $exit_litteral);
Expand Down Expand Up @@ -729,13 +729,13 @@ sub get_litteral_status {

sub is_status {
my ($self, %options) = @_;
# $options{value} = string status
# $options{value} = string status
# $options{litteral} = value is litteral
# $options{compare} = string status
# $options{compare} = string status

if (defined($options{litteral})) {
my $value = defined($options{value}) ? $options{value} : $self->get_litteral_status();

if (uc($value) eq uc($options{compare})) {
return 1;
}
Expand Down Expand Up @@ -906,7 +906,7 @@ sub parameter {

sub add_disco_entry {
my ($self, %options) = @_;

push @{$self->{disco_entries}}, {%options};
}

Expand Down Expand Up @@ -950,7 +950,7 @@ sub load_eval {
my ($self) = @_;

my ($code) = centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => 'Safe',
output => $self->{output}, module => 'Safe',
no_quit => 1
);
if ($code == 0) {
Expand Down Expand Up @@ -1140,8 +1140,8 @@ sub apply_pfdata_scale {

if (defined(${$options{perf}}->{max}) && ${$options{perf}}->{max} ne '') {
($value) = centreon::plugins::misc::scale_bytesbit(value => ${$options{perf}}->{max},
src_quantity => $src_quantity, src_unit => $src_unit,
dst_quantity => defined($dst_unit) ? $dst_quantity : $options{args}->{quantity},
src_quantity => $src_quantity, src_unit => $src_unit,
dst_quantity => defined($dst_unit) ? $dst_quantity : $options{args}->{quantity},
dst_unit => defined($dst_unit) ? $dst_unit : $options{args}->{unit});
${$options{perf}}->{max} = sprintf('%.2f', $value);
}
Expand All @@ -1153,14 +1153,14 @@ sub apply_pfdata_scale {

if ($result->{start} ne '' && $result->{infinite_neg} == 0) {
($result->{start}) = centreon::plugins::misc::scale_bytesbit(value => $result->{start},
src_quantity => $src_quantity, src_unit => $src_unit,
dst_quantity => defined($dst_unit) ? $dst_quantity : $options{args}->{quantity},
src_quantity => $src_quantity, src_unit => $src_unit,
dst_quantity => defined($dst_unit) ? $dst_quantity : $options{args}->{quantity},
dst_unit => defined($dst_unit) ? $dst_unit : $options{args}->{unit});
}
if ($result->{end} ne '' && $result->{infinite_pos} == 0) {
($result->{end}) = centreon::plugins::misc::scale_bytesbit(value => $result->{end},
src_quantity => $src_quantity, src_unit => $src_unit,
dst_quantity => defined($dst_unit) ? $dst_quantity : $options{args}->{quantity},
src_quantity => $src_quantity, src_unit => $src_unit,
dst_quantity => defined($dst_unit) ? $dst_quantity : $options{args}->{quantity},
dst_unit => defined($dst_unit) ? $dst_unit : $options{args}->{unit});
}

Expand Down Expand Up @@ -1216,7 +1216,7 @@ sub apply_pfdata_percent {
${$options{perf}}->{$threshold} = centreon::plugins::misc::get_threshold_litteral(%$result);
}

${$options{perf}}->{max} = 100;
${$options{perf}}->{max} = 100;
}

sub apply_pfdata_eval {
Expand Down Expand Up @@ -1364,7 +1364,7 @@ sub parse_perfdata_extend_args {
my ($self, %options) = @_;

# --extend-perfdata=searchlabel,newlabel,method[,[newuom],[min],[max],[warning],[critical]]
my ($pfdata_match, $pfdata_substitute, $method, $uom_sub, $min_sub, $max_sub, $warn_sub, $crit_sub) =
my ($pfdata_match, $pfdata_substitute, $method, $uom_sub, $min_sub, $max_sub, $warn_sub, $crit_sub) =
split /,/, $options{arg};
return if ((!defined($pfdata_match) || $pfdata_match eq '') && $options{type} != 3);

Expand Down Expand Up @@ -1539,29 +1539,29 @@ remove all metrics whose value equals 0 and that don't have a maximum value.
=item B<--explode-perfdata-max>

Create a new metric for each metric that comes with a maximum limit. The new
metric will be named identically with a '_max' suffix).
metric will be named identically with a '_max' suffix).
Example: it will split 'used_prct'=26.93%;0:80;0:90;0;100
into 'used_prct'=26.93%;0:80;0:90;0;100 'used_prct_max'=100%;;;;


=item B<--change-perfdata> B<--extend-perfdata>
=item B<--change-perfdata> B<--extend-perfdata>

Change or extend perfdata.
Change or extend perfdata.
Syntax: --extend-perfdata=searchlabel,newlabel,target[,[newuom],[min],[max]]

Common examples:

=over 4

Convert storage free perfdata into used: --change-perfdata=free,used,invert()
Convert storage free perfdata into used: --change-perfdata='free,used,invert()'

Convert storage free perfdata into used: --change-perfdata=used,free,invert()
Convert storage free perfdata into used: --change-perfdata='used,free,invert()'

Scale traffic values automatically: --change-perfdata=traffic,,scale(auto)
Scale traffic values automatically: --change-perfdata='traffic,,scale(auto)'

Scale traffic values in Mbps: --change-perfdata=traffic_in,,scale(Mbps),mbps
Scale traffic values in Mbps: --change-perfdata='traffic_in,,scale(Mbps),mbps'

Change traffic values in percent: --change-perfdata=traffic_in,,percent()
Change traffic values in percent: --change-perfdata='traffic_in,,percent()'

=back

Expand Down Expand Up @@ -1622,7 +1622,7 @@ and an output.

=item B<--output-ignore-label>

Remove the status label ("OK:", "WARNING:", "UNKNOWN:", CRITICAL:") from the
Remove the status label ("OK:", "WARNING:", "UNKNOWN:", CRITICAL:") from the
beginning of the output.
Example: 'OK: Ram Total:...' will become 'Ram Total:...'

Expand Down
Loading