diff --git a/zabbix_scripts/check_elasticsearch b/zabbix_scripts/check_elasticsearch index 3851102..8cf4edd 100644 --- a/zabbix_scripts/check_elasticsearch +++ b/zabbix_scripts/check_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}; } diff --git a/zabbix_scripts/disco_elasticsearch b/zabbix_scripts/disco_elasticsearch index bae9227..911b42a 100644 --- a/zabbix_scripts/disco_elasticsearch +++ b/zabbix_scripts/disco_elasticsearch @@ -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} }; } }