From dd7a138c4edf1a231f90a807f010840de284d532 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 7 Oct 2019 14:30:05 +0200 Subject: [PATCH] add mode status in openmetrics output --- centreon-plugins/centreon/plugins/output.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/centreon-plugins/centreon/plugins/output.pm b/centreon-plugins/centreon/plugins/output.pm index 1ef936100..6604747d9 100644 --- a/centreon-plugins/centreon/plugins/output.pm +++ b/centreon-plugins/centreon/plugins/output.pm @@ -386,6 +386,8 @@ sub output_openmetrics { my $time_ms = int(Time::HiRes::time() * 1000); $self->change_perfdata(); + + $self->perfdata_add(nlabel => 'plugin.mode.status', value => $self->{errors}->{$self->{myerrors}->{$self->{global_status}}}); foreach my $perf (@{$self->{perfdatas}}) { next if (defined($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->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);