Tweak elasticsearch monitoring scripts

tags/zabbix-agent-addons-0.2.153-1
Daniel Berteaud 3 years ago
parent 415c608252
commit 5387ae53b8
  1. 9
      zabbix_scripts/check_elasticsearch
  2. 15
      zabbix_scripts/disco_elasticsearch

@ -66,7 +66,14 @@ $ua->env_proxy;
if ($cluster){
$json = make_request('/_cluster/stats');
} elsif (defined $node){
$json = make_request('/_nodes/' . $node);
my $resp = make_request('/_nodes/' . $node)->{'nodes'};
# We can specify node by ID, name or IP
if (defined $resp->{$node}){
$json = $resp->{$node};
} else {
my $node_id = (keys %{$resp})[0];
$json = $resp->{$node_id};
}
} elsif (defined $index){
$json = make_request('/_cluster/health/' . $index . '?level=indices')->{'indices'}->{$index};
}

@ -60,18 +60,21 @@ my $ua = LWP::UserAgent->new(
$ua->env_proxy;
if ($nodes){
foreach (@{make_request('/_cat/nodes?format=json')}){
foreach (@{make_request('/_cat/nodes?format=json&full_id&h=ip,role,master,name,id,version')}){
push @{$json}, {
'{#ES_NODE_NAME}' => $_->{name},
'{#ES_NODE_ROLE}' => $_->{'node.role'}
'{#ES_NODE_NAME}' => $_->{name},
'{#ES_NODE_ROLE}' => $_->{role},
'{#ES_NODE_ID}' => $_->{id},
'{#ES_NODE_VERSION}' => $_->{version},
'{#ES_NODE_MASTER}' => $_->{master}
};
}
} elsif ($indices){
foreach (@{make_request('/_cat/indices?format=json')}){
push @{$json}, {
'{#ES_INDICE_NAME}' => $_->{index},
'{#ES_INDICE_STATUS}' => $_->{status},
'{#ES_INDICE_UUID}' => $_->{uuid}
'{#ES_INDEX_NAME}' => $_->{index},
'{#ES_INDEX_STATUS}' => $_->{status},
'{#ES_INDEX_UUID}' => $_->{uuid}
};
}
}

Loading…
Cancel
Save