From 060d45fe6955543a142849a786fccc5c38b50738 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 25 Jun 2013 17:49:13 -0400 Subject: [PATCH 01/12] Can define with env.host --- elasticsearch_cache | 2 +- elasticsearch_cluster_shards | 2 +- elasticsearch_docs | 2 +- elasticsearch_index_size | 2 +- elasticsearch_jvm_memory | 2 +- elasticsearch_jvm_threads | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/elasticsearch_cache b/elasticsearch_cache index 4e6b945..fea2a94 100755 --- a/elasticsearch_cache +++ b/elasticsearch_cache @@ -36,7 +36,7 @@ Tomas Doran (t0m) - c<< >> =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; my $ua = LWP::UserAgent->new; $ua->timeout(10); diff --git a/elasticsearch_cluster_shards b/elasticsearch_cluster_shards index 56ce429..7113e55 100755 --- a/elasticsearch_cluster_shards +++ b/elasticsearch_cluster_shards @@ -36,7 +36,7 @@ Tomas Doran (t0m) - c<< >> =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; my $ua = LWP::UserAgent->new; $ua->timeout(10); diff --git a/elasticsearch_docs b/elasticsearch_docs index 5d1e53c..d8cbabd 100755 --- a/elasticsearch_docs +++ b/elasticsearch_docs @@ -36,7 +36,7 @@ Tomas Doran (t0m) - c<< >> =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; my $ua = LWP::UserAgent->new; $ua->timeout(10); diff --git a/elasticsearch_index_size b/elasticsearch_index_size index c7daeb5..acabfe7 100755 --- a/elasticsearch_index_size +++ b/elasticsearch_index_size @@ -36,7 +36,7 @@ Tomas Doran (t0m) - c<< >> =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; my $ua = LWP::UserAgent->new; $ua->timeout(10); diff --git a/elasticsearch_jvm_memory b/elasticsearch_jvm_memory index 9c3bc40..ba18eea 100755 --- a/elasticsearch_jvm_memory +++ b/elasticsearch_jvm_memory @@ -36,7 +36,7 @@ Tomas Doran (t0m) - c<< >> =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; my $ua = LWP::UserAgent->new; $ua->timeout(10); diff --git a/elasticsearch_jvm_threads b/elasticsearch_jvm_threads index 794c397..a1daee0 100755 --- a/elasticsearch_jvm_threads +++ b/elasticsearch_jvm_threads @@ -36,7 +36,7 @@ Tomas Doran (t0m) - c<< >> =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; my $ua = LWP::UserAgent->new; $ua->timeout(10); From 45d7a0864a4ac6c941b3de9b19c3ace0ced4171e Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 25 Jun 2013 21:57:43 -0400 Subject: [PATCH 02/12] Allow override port value with env.port --- elasticsearch_cache | 5 +++-- elasticsearch_cluster_shards | 3 ++- elasticsearch_docs | 5 +++-- elasticsearch_index_size | 5 +++-- elasticsearch_jvm_memory | 3 ++- elasticsearch_jvm_threads | 5 +++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/elasticsearch_cache b/elasticsearch_cache index fea2a94..9e71076 100755 --- a/elasticsearch_cache +++ b/elasticsearch_cache @@ -37,6 +37,7 @@ Tomas Doran (t0m) - c<< >> =cut my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -50,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:9200/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); +my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); my %out; foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_cluster_shards b/elasticsearch_cluster_shards index 7113e55..9ef5d92 100755 --- a/elasticsearch_cluster_shards +++ b/elasticsearch_cluster_shards @@ -37,6 +37,7 @@ Tomas Doran (t0m) - c<< >> =cut my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -50,7 +51,7 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/health"); +my $data = get_json_from_url("http://$host:$port/_cluster/health"); if ($ARGV[0] and $ARGV[0] eq 'config') { print "graph_title ElasticSearch cluster shards\n"; diff --git a/elasticsearch_docs b/elasticsearch_docs index d8cbabd..8f15567 100755 --- a/elasticsearch_docs +++ b/elasticsearch_docs @@ -37,6 +37,7 @@ Tomas Doran (t0m) - c<< >> =cut my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -50,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:9200/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); +my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); my %out; foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_index_size b/elasticsearch_index_size index acabfe7..5a39926 100755 --- a/elasticsearch_index_size +++ b/elasticsearch_index_size @@ -37,6 +37,7 @@ Tomas Doran (t0m) - c<< >> =cut my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -50,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:9200/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); +my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); my %out; foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_jvm_memory b/elasticsearch_jvm_memory index ba18eea..07ef211 100755 --- a/elasticsearch_jvm_memory +++ b/elasticsearch_jvm_memory @@ -37,6 +37,7 @@ Tomas Doran (t0m) - c<< >> =cut my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -50,7 +51,7 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/nodes?jvm=true"); +my $data = get_json_from_url("http://$host:$port/_cluster/nodes?jvm=true"); my %out; foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_jvm_threads b/elasticsearch_jvm_threads index a1daee0..04b281f 100755 --- a/elasticsearch_jvm_threads +++ b/elasticsearch_jvm_threads @@ -37,6 +37,7 @@ Tomas Doran (t0m) - c<< >> =cut my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -50,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/nodes?jvm=true"); -my $t_data = get_json_from_url("http://$host:9200/_cluster/nodes/stats?jvm=true"); +my $data = get_json_from_url("http://$host:$port/_cluster/nodes?jvm=true"); +my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats?jvm=true"); my %out; foreach my $full_node_name (keys %{$data->{nodes}}) { From 9becf4f0fc521437a478903bf77ff5c55efe3b57 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 25 Jun 2013 22:30:46 -0400 Subject: [PATCH 03/12] Initialize variables to zero and use sum of all nodes instead of last one --- elasticsearch_cache | 9 +++++---- elasticsearch_docs | 4 ++-- elasticsearch_index_size | 4 ++-- elasticsearch_jvm_memory | 5 +++-- elasticsearch_jvm_threads | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/elasticsearch_cache b/elasticsearch_cache index 9e71076..29f34fa 100755 --- a/elasticsearch_cache +++ b/elasticsearch_cache @@ -53,13 +53,14 @@ sub get_json_from_url { my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); -my %out; +my %out = (field_size => 0, filter_size => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { next unless $t_data->{nodes}{$full_node_name}; - $out{field_size} = $t_data->{nodes}{$full_node_name}{indices}{cache}{field_size_in_bytes}; - $out{filter_size} = $t_data->{nodes}{$full_node_name}{indices}{cache}{filter_size_in_bytes}; - + if (defined($t_data->{nodes}{$full_node_name}{indices}{cache})) { + $out{field_size} += $t_data->{nodes}{$full_node_name}{indices}{cache}{field_size_in_bytes}; + $out{filter_size} += $t_data->{nodes}{$full_node_name}{indices}{cache}{filter_size_in_bytes}; + } } if ($ARGV[0] and $ARGV[0] eq 'config') { print "graph_args --base 1024\n"; diff --git a/elasticsearch_docs b/elasticsearch_docs index 8f15567..404e9f7 100755 --- a/elasticsearch_docs +++ b/elasticsearch_docs @@ -53,11 +53,11 @@ sub get_json_from_url { my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); -my %out; +my %out = (num_docs => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { next unless $t_data->{nodes}{$full_node_name}; - $out{num_docs} = $t_data->{nodes}{$full_node_name}{indices}{docs}{count}; + $out{num_docs} += $t_data->{nodes}{$full_node_name}{indices}{docs}{count}; } if ($ARGV[0] and $ARGV[0] eq 'config') { diff --git a/elasticsearch_index_size b/elasticsearch_index_size index 5a39926..d749524 100755 --- a/elasticsearch_index_size +++ b/elasticsearch_index_size @@ -53,11 +53,11 @@ sub get_json_from_url { my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); -my %out; +my %out = (index_size => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { next unless $t_data->{nodes}{$full_node_name}; - $out{index_size} = $t_data->{nodes}{$full_node_name}{indices}{store}{size_in_bytes}; + $out{index_size} += $t_data->{nodes}{$full_node_name}{indices}{store}{size_in_bytes}; } if ($ARGV[0] and $ARGV[0] eq 'config') { print "graph_args --base 1024\n"; diff --git a/elasticsearch_jvm_memory b/elasticsearch_jvm_memory index 07ef211..82198c8 100755 --- a/elasticsearch_jvm_memory +++ b/elasticsearch_jvm_memory @@ -52,12 +52,13 @@ sub get_json_from_url { } my $data = get_json_from_url("http://$host:$port/_cluster/nodes?jvm=true"); -my %out; +my %out = (direct_max => 0, heap_init =>0, heap_max => 0, non_heap_init => 0, non_heap_max => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { + next unless $data->{nodes}{$full_node_name}; foreach my $name (grep { /_in_bytes$/ } keys %{ $data->{nodes}{$full_node_name}{jvm}{mem} }) { my ($dname) = $name =~ m/(.+)_in_bytes$/; - $out{$dname} = $data->{nodes}{$full_node_name}{jvm}{mem}{$name}; + $out{$dname} += $data->{nodes}{$full_node_name}{jvm}{mem}{$name}; } } if ($ARGV[0] and $ARGV[0] eq 'config') { diff --git a/elasticsearch_jvm_threads b/elasticsearch_jvm_threads index 04b281f..a220d73 100755 --- a/elasticsearch_jvm_threads +++ b/elasticsearch_jvm_threads @@ -53,12 +53,12 @@ sub get_json_from_url { my $data = get_json_from_url("http://$host:$port/_cluster/nodes?jvm=true"); my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats?jvm=true"); -my %out; +my %out = (count => 0, peak_count => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { next unless $t_data->{nodes}{$full_node_name}; foreach my $name (keys %{ $t_data->{nodes}{$full_node_name}{jvm}{threads} }) { - $out{$name} = $t_data->{nodes}{$full_node_name}{jvm}{threads}{$name}; + $out{$name} += $t_data->{nodes}{$full_node_name}{jvm}{threads}{$name}; } } if ($ARGV[0] and $ARGV[0] eq 'config') { From 3b98a956431445972b0fd9a10e17ed05e0dc3e45 Mon Sep 17 00:00:00 2001 From: Patrick McAndrew Date: Thu, 26 Sep 2013 16:08:51 +0100 Subject: [PATCH 04/12] add index total stats --- elasticsearch_index_total | 97 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 elasticsearch_index_total diff --git a/elasticsearch_index_total b/elasticsearch_index_total new file mode 100755 index 0000000..87a164d --- /dev/null +++ b/elasticsearch_index_total @@ -0,0 +1,97 @@ +#!/usr/bin/env perl + +# Parameters supported: +# +# config +# autoconf +# +# Magic markers: +#%# family=auto +#%# capabilities=autoconf + +use strict; +use warnings; +use LWP; +use JSON qw/decode_json/; + +=head1 NAME + +elasticsearch_index_total - A munin plugin that collects stats about the index totals + +=head1 APPLICABLE SYSTEMS + +ElasticSearch + +=head1 CONFIGURATION + +None + +=head1 BUGS + +None known so far. If you find any, let me know. + +=head1 AUTHOR + + +=cut + +my $host = 'localhost'; + +my $ua = LWP::UserAgent->new; +$ua->timeout(10); + +sub get_json_from_url { + my $uri = shift; + my $res = $ua->get($uri, 'Content-Type' => 'application/json' ); + Carp::confess($res->code . " for " . $uri) unless $res->is_success; + my $data = do { local $@; eval { decode_json($res->content) } }; + die("Could not decode JSON from: " . $res->content) unless $data; + return $data; +} + +my $data = get_json_from_url("http://$host:9200/_cluster/nodes"); +my $t_data = get_json_from_url("http://$host:9200/_cluster/nodes/stats"); +my %out; + +foreach my $full_node_name (keys %{$data->{nodes}}) { + next unless $t_data->{nodes}{$full_node_name}; + $out{index} = $t_data->{nodes}{$full_node_name}{indices}{indexing}{index_total}; + $out{get} = $t_data->{nodes}{$full_node_name}{indices}{get}{total}; + $out{search} = $t_data->{nodes}{$full_node_name}{indices}{search}{query_total}; + $out{delete} = $t_data->{nodes}{$full_node_name}{indices}{indexing}{delete_total}; +} +if ($ARGV[0] and $ARGV[0] eq 'config') { + print "graph_title elasticsearch index operations\n"; + print "graph_category elasticsearch\n"; + print "graph_args --base 1000 -l 0\n"; + print "graph_vlabel Operations per second\n"; + + print "graph_order index get search delete\n"; + print "index.label index\n"; + print "index.type DERIVE\n"; + print "index.min 0\n"; + print "index.draw LINE2\n"; + + print "get.label get\n"; + print "get.type DERIVE\n"; + print "get.min 0\n"; + print "get.draw LINE2\n"; + + print "search.label search\n"; + print "search.type DERIVE\n"; + print "search.min 0\n"; + print "search.draw LINE2\n"; + + print "delete.label delete\n"; + print "delete.type DERIVE\n"; + print "delete.min 0\n"; + print "delete.draw LINE2\n"; + +} +elsif (!$ARGV[0] || $ARGV[0] eq 'autoconf') { + foreach my $name (keys %out) { + print "$name.value " . $out{$name} . "\n"; + } +} + +exit(0); From b07f69351632a75bd1eac8ba7acdf2551e76899c Mon Sep 17 00:00:00 2001 From: y-ken Date: Tue, 22 Apr 2014 11:11:14 +0900 Subject: [PATCH 05/12] Fixed working for elasticsearch 1.0 --- elasticsearch_cache | 4 ++-- elasticsearch_docs | 4 ++-- elasticsearch_index_size | 4 ++-- elasticsearch_index_total | 7 ++++--- elasticsearch_jvm_memory | 2 +- elasticsearch_jvm_threads | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/elasticsearch_cache b/elasticsearch_cache index 29f34fa..43f2526 100755 --- a/elasticsearch_cache +++ b/elasticsearch_cache @@ -51,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:$port/_nodes"); +my $t_data = get_json_from_url("http://$host:$port/_nodes/stats"); my %out = (field_size => 0, filter_size => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_docs b/elasticsearch_docs index 404e9f7..d43801d 100755 --- a/elasticsearch_docs +++ b/elasticsearch_docs @@ -51,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:$port/_nodes"); +my $t_data = get_json_from_url("http://$host:$port/_nodes/stats"); my %out = (num_docs => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_index_size b/elasticsearch_index_size index d749524..266e851 100755 --- a/elasticsearch_index_size +++ b/elasticsearch_index_size @@ -51,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:$port/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:$port/_nodes"); +my $t_data = get_json_from_url("http://$host:$port/_nodes/stats"); my %out = (index_size => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_index_total b/elasticsearch_index_total index 87a164d..806fa43 100755 --- a/elasticsearch_index_total +++ b/elasticsearch_index_total @@ -35,7 +35,8 @@ None known so far. If you find any, let me know. =cut -my $host = 'localhost'; +my $host = exists $ENV{'host'} ? $ENV{'host'} : 'localhost'; +my $port = exists $ENV{'port'} ? $ENV{'port'} : 9200; my $ua = LWP::UserAgent->new; $ua->timeout(10); @@ -49,8 +50,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:9200/_cluster/nodes"); -my $t_data = get_json_from_url("http://$host:9200/_cluster/nodes/stats"); +my $data = get_json_from_url("http://$host:9200/_nodes"); +my $t_data = get_json_from_url("http://$host:9200/_nodes/stats"); my %out; foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_jvm_memory b/elasticsearch_jvm_memory index 82198c8..129b691 100755 --- a/elasticsearch_jvm_memory +++ b/elasticsearch_jvm_memory @@ -51,7 +51,7 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:$port/_cluster/nodes?jvm=true"); +my $data = get_json_from_url("http://$host:$port/_nodes?jvm=true"); my %out = (direct_max => 0, heap_init =>0, heap_max => 0, non_heap_init => 0, non_heap_max => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { diff --git a/elasticsearch_jvm_threads b/elasticsearch_jvm_threads index a220d73..69e0854 100755 --- a/elasticsearch_jvm_threads +++ b/elasticsearch_jvm_threads @@ -51,8 +51,8 @@ sub get_json_from_url { return $data; } -my $data = get_json_from_url("http://$host:$port/_cluster/nodes?jvm=true"); -my $t_data = get_json_from_url("http://$host:$port/_cluster/nodes/stats?jvm=true"); +my $data = get_json_from_url("http://$host:$port/_nodes?jvm=true"); +my $t_data = get_json_from_url("http://$host:$port/_nodes/stats?jvm=true"); my %out = (count => 0, peak_count => 0); foreach my $full_node_name (keys %{$data->{nodes}}) { From 22f244f77e6d27791de4ae5413cc7c74b7b3e8e0 Mon Sep 17 00:00:00 2001 From: y-ken Date: Tue, 22 Apr 2014 11:32:44 +0900 Subject: [PATCH 06/12] Fixed: 'Max open files' as variant number --- elasticsearch_open_files | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elasticsearch_open_files b/elasticsearch_open_files index b72870e..136b54c 100755 --- a/elasticsearch_open_files +++ b/elasticsearch_open_files @@ -22,5 +22,6 @@ fi PID=`ps -u elasticsearch -opid,comm | grep java | awk '{ print $1 }'` VALUE=`ls /proc/$PID/fd/ | wc | awk '{ print $1 }'` +MAX_VALUE=`grep 'Max open files' /proc/$PID/limits | awk '{ print $5 }'` echo "used.value $VALUE" -echo "max.value 65000" +echo "max.value $MAX_VALUE" From e22b8d727207f17c0ba06a8cda389c2adff263e0 Mon Sep 17 00:00:00 2001 From: y-ken Date: Tue, 22 Apr 2014 15:48:23 +0900 Subject: [PATCH 07/12] Remove usuless comment --- elasticsearch_open_files | 3 --- 1 file changed, 3 deletions(-) diff --git a/elasticsearch_open_files b/elasticsearch_open_files index 136b54c..41671df 100755 --- a/elasticsearch_open_files +++ b/elasticsearch_open_files @@ -17,9 +17,6 @@ if [ "$1" = "config" ]; then exit 0 fi - -# while true; do su -c 'ls /proc/$(pidof whatever)/fd' elasticsearch |wc -l |nc -l -q0 localhost 9998; done - PID=`ps -u elasticsearch -opid,comm | grep java | awk '{ print $1 }'` VALUE=`ls /proc/$PID/fd/ | wc | awk '{ print $1 }'` MAX_VALUE=`grep 'Max open files' /proc/$PID/limits | awk '{ print $5 }'` From 847ba13305c0bfb46a71c2cb0b5ab98ea5a27246 Mon Sep 17 00:00:00 2001 From: y-ken Date: Tue, 22 Apr 2014 15:49:14 +0900 Subject: [PATCH 08/12] Fixed translog directory detection --- elasticsearch_translog_size | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/elasticsearch_translog_size b/elasticsearch_translog_size index 7f9260c..0dc34e6 100755 --- a/elasticsearch_translog_size +++ b/elasticsearch_translog_size @@ -18,7 +18,8 @@ if [ "$1" = "config" ]; then exit 0 fi -NUMBER=`ls /srv/elasticsearch/metacpan_v1/nodes/0/indices/*/*/translog/* | wc -l` -SIZE=`du -s /srv/elasticsearch/metacpan_v1/nodes/0/indices/*/*/translog/* | awk '{sum+=$1};END{print sum}'` +DIR=`ps -u elasticsearch -opid,command |tail -1| perl -ne 'print $1 if(/-Des.default.path.data=([\w\/]+)/)'` +NUMBER=`ls $DIR/*/nodes/0/indices/*/*/translog/* | wc -l` +SIZE=`du -s $DIR/*/nodes/0/indices/*/*/translog/* | awk '{sum+=$1};END{print sum}'` echo "number.value $NUMBER" echo "size.value $SIZE" From 30a5fc8c9226f8205cf1ea6cdf4be9e03d440cab Mon Sep 17 00:00:00 2001 From: y-ken Date: Tue, 22 Apr 2014 17:34:01 +0900 Subject: [PATCH 09/12] Update description --- elasticsearch_cache | 2 +- elasticsearch_cluster_shards | 2 +- elasticsearch_docs | 2 +- elasticsearch_index_size | 2 +- elasticsearch_jvm_memory | 2 +- elasticsearch_jvm_threads | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/elasticsearch_cache b/elasticsearch_cache index 43f2526..ae4473e 100755 --- a/elasticsearch_cache +++ b/elasticsearch_cache @@ -16,7 +16,7 @@ use JSON qw/decode_json/; =head1 NAME -elasticsearch_jvm - A munin plugin that collects stats from the JVM of your elasticsearch instances +elasticsearch_cache - A munin plugin that collects cache stats of your elasticsearch instances =head1 APPLICABLE SYSTEMS diff --git a/elasticsearch_cluster_shards b/elasticsearch_cluster_shards index 9ef5d92..d3d88db 100755 --- a/elasticsearch_cluster_shards +++ b/elasticsearch_cluster_shards @@ -16,7 +16,7 @@ use JSON qw/decode_json/; =head1 NAME -elasticsearch_jvm - A munin plugin that collects stats from the JVM of your elasticsearch instances +elasticsearch_cluster_shards - A munin plugin that collects shard stats of your elasticsearch instances =head1 APPLICABLE SYSTEMS diff --git a/elasticsearch_docs b/elasticsearch_docs index d43801d..a2d9cd3 100755 --- a/elasticsearch_docs +++ b/elasticsearch_docs @@ -16,7 +16,7 @@ use JSON qw/decode_json/; =head1 NAME -elasticsearch_jvm - A munin plugin that collects stats from the JVM of your elasticsearch instances +elasticsearch_docs - A munin plugin that collects document stats of your elasticsearch instances =head1 APPLICABLE SYSTEMS diff --git a/elasticsearch_index_size b/elasticsearch_index_size index 266e851..685d45c 100755 --- a/elasticsearch_index_size +++ b/elasticsearch_index_size @@ -16,7 +16,7 @@ use JSON qw/decode_json/; =head1 NAME -elasticsearch_jvm - A munin plugin that collects stats from the JVM of your elasticsearch instances +elasticsearch_index_size - A munin plugin that collects index size of your elasticsearch instances =head1 APPLICABLE SYSTEMS diff --git a/elasticsearch_jvm_memory b/elasticsearch_jvm_memory index 129b691..9b25b0f 100755 --- a/elasticsearch_jvm_memory +++ b/elasticsearch_jvm_memory @@ -16,7 +16,7 @@ use JSON qw/decode_json/; =head1 NAME -elasticsearch_jvm - A munin plugin that collects stats from the JVM of your elasticsearch instances +elasticsearch_jvm_memory - A munin plugin that collects stats from the JVM of your elasticsearch instances =head1 APPLICABLE SYSTEMS diff --git a/elasticsearch_jvm_threads b/elasticsearch_jvm_threads index 69e0854..5418b40 100755 --- a/elasticsearch_jvm_threads +++ b/elasticsearch_jvm_threads @@ -16,7 +16,7 @@ use JSON qw/decode_json/; =head1 NAME -elasticsearch_jvm - A munin plugin that collects stats from the JVM of your elasticsearch instances +elasticsearch_jvm_threads - A munin plugin that collects stats from the JVM of your elasticsearch instances =head1 APPLICABLE SYSTEMS From 10dbf9dcee7c28a3e71f0c67b4be496b33c27f9b Mon Sep 17 00:00:00 2001 From: y-ken Date: Tue, 22 Apr 2014 17:34:08 +0900 Subject: [PATCH 10/12] Add README --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2f6e9a0 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Munin plugin for elasticsearch + +A useful Munin plugin for monitoring elasticsearch 1.x nodes in Perl.
+This original codes has out of maintenance, so I have started maintenance this plugin. + +## Plugins + +* elasticsearch_cache - field and filter cache stats * elasticsearch_cluster_shards - cluster shards stats * elasticsearch_docs - document count * elasticsearch_index_size - index size * elasticsearch_index_total - index total count * elasticsearch_jvm_memory - JVM heap stats * elasticsearch_jvm_threads - JVM thread stats * elasticsearch_open_files - open files count * elasticsearch_translog_size - translog file size + +## Configuration + +### Variables + +* env.host - a elasticsearch node capable of providing stats interface (default localhost) +* env.port - elasticsearch HTTP API port (default 9200) + +### Example Config + +setup this config adding into `/etc/munin/plugin-conf.d/munin-node` before install. + +``` +[elasticsearch_*] +env.host 10.1.2.14 +env.port 9200 + +[elasticsearch_open_files] +user root +env.host 10.1.2.14 +env.port 9200 +``` + +## Install + +Install this plugins with following steps after config setuped. + +```sh +# For centos +$ cd /usr/local/src/ +$ git clone https://github.com/y-ken/munin-plugin-elasticsearch.git +$ cd munin-plugin-elasticsearch +$ cp -p elasticsearch_* /usr/share/munin/plugins/ +$ ln -s /usr/share/munin/plugins/elasticsearch_* /etc/munin/plugins/ +$ sudo -H munin-node-configure --shell | grep elasticsearch | sudo -H sh +$ munin-node-configure | grep elasticsearch +$ service munin-node restart +``` + +## Copyright + +Original code has imported from https://gist.github.com/2159398 (made by [@rafl](https://github.com/rafl)) + +## Licence + +MIT License From a819cafa61726d9b6d070449597d6263dee58e75 Mon Sep 17 00:00:00 2001 From: y-ken Date: Wed, 23 Apr 2014 09:43:58 +0900 Subject: [PATCH 11/12] Update README --- README.md | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2f6e9a0..d29629d 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,33 @@ This original codes has out of maintenance, so I have started maintenance this p ### Example Config -setup this config adding into `/etc/munin/plugin-conf.d/munin-node` before install. +Before use, put these settings into munin configuration. + + * examples of munin config file + * in the case of all plugin config into single file.
+ `/etc/munin/plugin-conf.d/munin-node` + * in the case of creating file per plugins.
+ `/etc/munin/plugin-conf.d/elasticsearch` + +##### example of minimam configuration
+ +`elasticsearch_open_files` has required root privilege to read under the `/proc`. + +``` +[elasticsearch_open_files] +user root +``` + +##### example of custom host and port configuration ``` [elasticsearch_*] -env.host 10.1.2.14 +env.host localhost env.port 9200 [elasticsearch_open_files] user root -env.host 10.1.2.14 +env.host localhost env.port 9200 ``` @@ -45,9 +62,22 @@ $ munin-node-configure | grep elasticsearch $ service munin-node restart ``` -## Copyright +To confirm wokring fine or not, you can check like below. + +```sh +$ munin-run elasticsearch_jvm_memory +heap_init.value 8589934592 +non_heap_max.value 224395264 +heap_max.value 8520204288 +direct_max.value 8520204288 +non_heap_init.value 24313856 +``` + +## Author -Original code has imported from https://gist.github.com/2159398 (made by [@rafl](https://github.com/rafl)) +* Original code by [@rafl](https://github.com/rafl) has imported from https://gist.github.com/2159398 +* [Contributors to y-ken/munin-plugin-elasticsearch](https://github.com/y-ken/munin-plugin-elasticsearch/graphs/contributors) +* maintained by [@y-ken](https://github.com/y-ken) ## Licence From d5cdb9de0a9a22bfb27593e9c9f89ad5ea8eb222 Mon Sep 17 00:00:00 2001 From: y-ken Date: Thu, 24 Apr 2014 11:40:41 +0900 Subject: [PATCH 12/12] Fixed graph_category graph_category is should be elasticsearch --- elasticsearch_open_files | 2 +- elasticsearch_translog_size | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch_open_files b/elasticsearch_open_files index 41671df..b513735 100755 --- a/elasticsearch_open_files +++ b/elasticsearch_open_files @@ -8,7 +8,7 @@ if [ "$1" = "config" ]; then echo 'graph_title ElasticSearch open files' echo 'graph_args --base 1000 -l 0' echo 'graph_vlabel number of open files' - echo 'graph_category system' + echo 'graph_category elasticsearch' echo 'used.label open files' echo 'used.type GAUGE' echo 'used.info The number of currently open files.' diff --git a/elasticsearch_translog_size b/elasticsearch_translog_size index 0dc34e6..1d1e59d 100755 --- a/elasticsearch_translog_size +++ b/elasticsearch_translog_size @@ -10,7 +10,7 @@ if [ "$1" = "config" ]; then echo 'graph_title ElasticSearch translog size' echo 'graph_args --base 1024 -l 0' echo 'graph_vlabel size of translogs' - echo 'graph_category system' + echo 'graph_category elasticsearch' echo 'size.label size of translog files' echo 'size.type GAUGE' echo 'number.label number of translog files'