mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
Change type of the variable for json parsing
This commit is contained in:
parent
35b8045f04
commit
13f4d63b1d
@ -41,6 +41,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::httplib;
|
use centreon::plugins::httplib;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
my $thresholds = {
|
my $thresholds = {
|
||||||
indices => [
|
indices => [
|
||||||
@ -133,9 +134,10 @@ sub get_severity {
|
|||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."_cluster/health?level=indices";
|
$self->{option_results}->{url_path} = $self->{option_results}->{url_path}."_cluster/health";
|
||||||
|
my $query_form_get = { level => 'indices' };
|
||||||
|
|
||||||
my $jsoncontent = centreon::plugins::httplib::connect($self, connection_exit => 'critical');
|
my $jsoncontent = centreon::plugins::httplib::connect($self, query_form_get => $query_form_get, connection_exit => 'critical');
|
||||||
|
|
||||||
my $json = JSON->new;
|
my $json = JSON->new;
|
||||||
|
|
||||||
@ -154,21 +156,21 @@ sub run {
|
|||||||
short_msg => sprintf("All indices are in green state."));
|
short_msg => sprintf("All indices are in green state."));
|
||||||
|
|
||||||
my $exit = 'OK';
|
my $exit = 'OK';
|
||||||
my $status;
|
|
||||||
foreach my $indicename (sort(keys $webcontent->{indices})) {
|
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 ]);
|
$exit = $self->{output}->get_most_critical(status => [ $tmp_exit, $exit ]);
|
||||||
if (!$self->{output}->is_status(value => $tmp_exit, compare => 'OK', litteral => 1)) {
|
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",
|
$self->{output}->output_add(long_msg => sprintf("Indice %s status is in %s state",
|
||||||
$indicename, $webcontent->{indices}->{$indicename}->{status}));
|
$indicename, $webcontent->{indices}->{$indicename}->{status}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(severity => $exit,
|
||||||
short_msg => sprintf("One or some indices are in %s state", $map_states_indices{$exit}));
|
short_msg => sprintf("One or some indices are in %s state", $map_states_indices{$exit}));
|
||||||
|
|
||||||
$self->{output}->display(force_long_output => 1);
|
$self->{output}->display(force_long_output => 1);
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user