From eb847444747a70905b70a6e28e521b382690b479 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 21 Jul 2015 13:47:53 +0200 Subject: [PATCH] + Enhance elastic search --- apps/elasticsearch/mode/indices.pm | 7 ++----- apps/elasticsearch/mode/nodescount.pm | 8 -------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/apps/elasticsearch/mode/indices.pm b/apps/elasticsearch/mode/indices.pm index 5523c4208..ac8d29a90 100644 --- a/apps/elasticsearch/mode/indices.pm +++ b/apps/elasticsearch/mode/indices.pm @@ -125,7 +125,6 @@ sub run { my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical'); my $json = JSON->new; - my $webcontent; eval { @@ -139,11 +138,9 @@ sub run { $self->{output}->output_add(severity => 'OK', short_msg => sprintf("All indices are in green state.")); - my $exit = 'OK'; - foreach my $indicename (sort (keys %{$webcontent->{indices}})) { - my $tmp_exit = $self->get_severity(section => 'indices', value => $webcontent->{indices}->{$indicename}->{status}); + my $tmp_exit = $self->get_severity(section => 'indices', value => $webcontent->{indices}->{$indicename}->{status}); $exit = $self->{output}->get_most_critical(status => [ $tmp_exit, $exit ]); if (!$self->{output}->is_status(value => $tmp_exit, compare => 'OK', litteral => 1)) { $self->{output}->output_add(long_msg => sprintf("Indice %s status is in %s state", @@ -151,7 +148,7 @@ sub run { } } - if ($exit ne 'OK') { + if (!$self->{output}->is_status(value => $exit, compare => 'OK', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Some indices are in wrong state")); } diff --git a/apps/elasticsearch/mode/nodescount.pm b/apps/elasticsearch/mode/nodescount.pm index ab6139ba0..e5686f858 100644 --- a/apps/elasticsearch/mode/nodescount.pm +++ b/apps/elasticsearch/mode/nodescount.pm @@ -106,26 +106,18 @@ sub run { ); $self->{output}->perfdata_add(label => "nodemasteronly", value => $webcontent->{nodes}->{count}->{master_only}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, ); $self->{output}->perfdata_add(label => "nodedataonly", value => $webcontent->{nodes}->{count}->{data_only}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, ); $self->{output}->perfdata_add(label => "nodemasterdata", value => $webcontent->{nodes}->{count}->{master_data}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, ); $self->{output}->perfdata_add(label => "nodeclient", value => $webcontent->{nodes}->{count}->{client}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0, ); $self->{output}->display();