enh(ouput): remove pipe character if no perfdatas (#3370)

This commit is contained in:
qgarnier 2022-01-04 10:57:02 +01:00 committed by GitHub
parent 49236fb2bd
commit 3e4008e37e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -515,21 +515,24 @@ sub output_txt {
$self->output_txt_short(%options); $self->output_txt_short(%options);
if ($force_ignore_perfdata == 1) { if ($force_ignore_perfdata == 0) {
print "\n"; my $pipe = 0;
} else {
print '|';
$self->change_perfdata(); $self->change_perfdata();
foreach my $perf (@{$self->{perfdatas}}) { foreach my $perf (@{$self->{perfdatas}}) {
next if ($self->filter_perfdata(perf => $perf)); next if ($self->filter_perfdata(perf => $perf));
$perf->{unit} = '' if (defined($self->{option_results}->{filter_uom}) && $perf->{unit} = '' if (defined($self->{option_results}->{filter_uom}) &&
$perf->{unit} !~ /$self->{option_results}->{filter_uom}/); $perf->{unit} !~ /$self->{option_results}->{filter_uom}/);
$self->range_perfdata(ranges => [\$perf->{warning}, \$perf->{critical}]); $self->range_perfdata(ranges => [\$perf->{warning}, \$perf->{critical}]);
if ($pipe == 0) {
print '|';
$pipe = 1;
}
print " '" . $perf->{label} . "'=" . $perf->{value} . $perf->{unit} . ';' . $perf->{warning} . ';' . $perf->{critical} . ';' . $perf->{min} . ';' . $perf->{max}; print " '" . $perf->{label} . "'=" . $perf->{value} . $perf->{unit} . ';' . $perf->{warning} . ';' . $perf->{critical} . ';' . $perf->{min} . ';' . $perf->{max};
} }
print "\n";
} }
print "\n";
if (defined($self->{option_results}->{verbose}) || $force_long_output == 1) { if (defined($self->{option_results}->{verbose}) || $force_long_output == 1) {
if (scalar(@{$self->{global_long_output}})) { if (scalar(@{$self->{global_long_output}})) {
print join("\n", @{$self->{global_long_output}}); print join("\n", @{$self->{global_long_output}});