add mode status in openmetrics output

This commit is contained in:
garnier-quentin 2019-10-07 14:30:05 +02:00
parent 6519ef2b17
commit dd7a138c4e
1 changed files with 6 additions and 0 deletions

View File

@ -386,6 +386,8 @@ sub output_openmetrics {
my $time_ms = int(Time::HiRes::time() * 1000); my $time_ms = int(Time::HiRes::time() * 1000);
$self->change_perfdata(); $self->change_perfdata();
$self->perfdata_add(nlabel => 'plugin.mode.status', value => $self->{errors}->{$self->{myerrors}->{$self->{global_status}}});
foreach my $perf (@{$self->{perfdatas}}) { foreach my $perf (@{$self->{perfdatas}}) {
next if (defined($self->{option_results}->{filter_perfdata}) && next if (defined($self->{option_results}->{filter_perfdata}) &&
$perf->{label} !~ /$self->{option_results}->{filter_perfdata}/); $perf->{label} !~ /$self->{option_results}->{filter_perfdata}/);
@ -576,6 +578,10 @@ sub option_exit {
$self->output_json(exit_litteral => $exit_litteral, nolabel => $nolabel, force_ignore_perfdata => 1, force_long_output => 1); $self->output_json(exit_litteral => $exit_litteral, nolabel => $nolabel, force_ignore_perfdata => 1, force_long_output => 1);
$self->exit(exit_litteral => $exit_litteral); $self->exit(exit_litteral => $exit_litteral);
} }
} elsif (defined($self->{option_results}->{output_openmetrics})) {
$self->set_status(exit_litteral => $exit_litteral);
$self->output_openmetrics();
$self->exit(exit_litteral => $exit_litteral);
} }
$self->output_txt(exit_litteral => $exit_litteral, nolabel => $nolabel, force_ignore_perfdata => 1, force_long_output => 1); $self->output_txt(exit_litteral => $exit_litteral, nolabel => $nolabel, force_ignore_perfdata => 1, force_long_output => 1);