es-diag 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/es-diag.gemspec +1 -1
- data/lib/checks/local_node_jvm_heap.rb +36 -0
- data/lib/checks/ulimits.rb +1 -1
- data/lib/contexts/es_local_node.rb +22 -0
- data/lib/es-diag.rb +2 -10
- data/lib/es-diag/check.rb +2 -2
- data/lib/es-diag/cli.rb +12 -4
- data/lib/es-diag/context.rb +59 -0
- data/lib/es-diag/version.rb +1 -1
- data/resources/screen.png +0 -0
- metadata +21 -2
data/es-diag.gemspec
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
title "Recommended JVM Heap Size"
|
2
|
+
|
3
|
+
|
4
|
+
how_to """
|
5
|
+
Passing JVM level configuration (such as -X parameters) should be set
|
6
|
+
within the elasticsearch.conf file.
|
7
|
+
|
8
|
+
Use the ES_MIN_MEM and ES_MAX_MEM environment variables to set the minimum
|
9
|
+
and maximum memory allocation for the JVM (set in mega bytes). It defaults
|
10
|
+
to 256 and 1024 respectively.
|
11
|
+
"""
|
12
|
+
|
13
|
+
|
14
|
+
#
|
15
|
+
# for more detail about es_local_node data bag, see your own node
|
16
|
+
# http://localhost:9200/_cluster/nodes/_local
|
17
|
+
#
|
18
|
+
# for technical detail, see how fetching is implemented in
|
19
|
+
# /contexts/es_local_node.rb
|
20
|
+
#
|
21
|
+
if data.es_local_node
|
22
|
+
n = data.es_local_node.nodes.first[1]
|
23
|
+
totmem = n.os.mem.total_in_bytes
|
24
|
+
hmin = n.jvm.mem.heap_init_in_bytes
|
25
|
+
hmax = n.jvm.mem.heap_max_in_bytes
|
26
|
+
|
27
|
+
hmin_r = hmin / totmem
|
28
|
+
hmax_r = hmax / totmem
|
29
|
+
|
30
|
+
if hmin_r < 0.3
|
31
|
+
warn "Min heap size set to #{n.jvm.mem.heap_init}, which is less than 30% of system memory."
|
32
|
+
end
|
33
|
+
if hmax_r > 0.8
|
34
|
+
warn "Max heap size set to #{n.jvm.mem.heap_max}, which is more than 80% of system memory."
|
35
|
+
end
|
36
|
+
end
|
data/lib/checks/ulimits.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
|
5
|
+
title "ElasticSearch Local Node"
|
6
|
+
|
7
|
+
node_addr = ES::Diag::Config['es_local_node']
|
8
|
+
|
9
|
+
unless node_addr
|
10
|
+
warn "Skipping (no node host provided)."
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
cdata = JSON.parse open("http://#{node_addr}/_cluster/nodes/_local").read
|
16
|
+
context "es_local_node", cdata
|
17
|
+
rescue
|
18
|
+
error "Gathering local node data: #{$!}"
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
data/lib/es-diag.rb
CHANGED
@@ -4,18 +4,10 @@ require 'ohai'
|
|
4
4
|
|
5
5
|
module ES
|
6
6
|
module Diag
|
7
|
-
|
8
|
-
def self.data
|
9
|
-
unless @ohai
|
10
|
-
Ohai::Config[:plugin_path] << File.expand_path('ohai_plugins', File.dirname(__FILE__))
|
11
|
-
@ohai= Ohai::System.new
|
12
|
-
@ohai.all_plugins
|
13
|
-
end
|
14
|
-
@ohai
|
15
|
-
end
|
16
|
-
end
|
7
|
+
Config = {}
|
17
8
|
end
|
18
9
|
end
|
19
10
|
|
11
|
+
require 'es-diag/context'
|
20
12
|
require 'es-diag/check'
|
21
13
|
|
data/lib/es-diag/check.rb
CHANGED
@@ -8,7 +8,7 @@ class ES::Diag::Check
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def data
|
11
|
-
ES::Diag::Context.data
|
11
|
+
@data ||= ES::Diag::Context.new(@ui).data
|
12
12
|
end
|
13
13
|
|
14
14
|
def how_to(text)
|
@@ -37,7 +37,7 @@ class ES::Diag::Check
|
|
37
37
|
@ui.warn "- #{warning}"
|
38
38
|
end
|
39
39
|
if @run_context[:help]
|
40
|
-
@ui.info "\n\
|
40
|
+
@ui.info "\n\n#{@ui.em 'Use these instructions to amend the problems:'}"
|
41
41
|
@ui.info @run_context[:help] + "\n"
|
42
42
|
end
|
43
43
|
end
|
data/lib/es-diag/cli.rb
CHANGED
@@ -6,18 +6,18 @@ require 'es-diag'
|
|
6
6
|
class ES::Diag::CLI < Thor
|
7
7
|
|
8
8
|
desc "status", "report back current status and recommendations."
|
9
|
-
def status
|
10
|
-
|
9
|
+
def status(cluster_node=nil)
|
10
|
+
info "Checking..."
|
11
|
+
ES::Diag::Config['es_local_node'] = cluster_node
|
11
12
|
c = ES::Diag::Check.new(self)
|
12
13
|
c.all_checks
|
13
|
-
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
17
|
|
18
18
|
no_tasks do
|
19
19
|
def title(text)
|
20
|
-
say "* #{text}"
|
20
|
+
say "\n* #{text}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def info(detail=nil)
|
@@ -27,6 +27,14 @@ class ES::Diag::CLI < Thor
|
|
27
27
|
def warn(detail)
|
28
28
|
say detail, :yellow
|
29
29
|
end
|
30
|
+
|
31
|
+
def error(detail)
|
32
|
+
say detail, :red
|
33
|
+
end
|
34
|
+
|
35
|
+
def em(text)
|
36
|
+
shell.set_color(text, nil, true)
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
|
3
|
+
module ES
|
4
|
+
module Diag
|
5
|
+
class Context
|
6
|
+
|
7
|
+
def initialize(ui)
|
8
|
+
@ui=ui
|
9
|
+
end
|
10
|
+
|
11
|
+
def warn(text)
|
12
|
+
@ui.warn "[#{@run_context[:title]}] #{text}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def error(text)
|
16
|
+
@ui.warn "[#{@run_context[:title]}] #{text}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def title(text)
|
20
|
+
@run_context[:title] = text
|
21
|
+
end
|
22
|
+
|
23
|
+
def context(k,v)
|
24
|
+
@run_context[:context] = {:key => k, :val => v}
|
25
|
+
end
|
26
|
+
|
27
|
+
def data
|
28
|
+
unless @ohai
|
29
|
+
@ui.info("Collecting system information...")
|
30
|
+
Ohai::Config[:plugin_path] << File.expand_path('../ohai_plugins', File.dirname(__FILE__))
|
31
|
+
@ohai = Ohai::System.new
|
32
|
+
@ohai.all_plugins
|
33
|
+
|
34
|
+
#enrich base data
|
35
|
+
@ui.info("Collecting extra information...")
|
36
|
+
all_contexts
|
37
|
+
end
|
38
|
+
@ohai
|
39
|
+
end
|
40
|
+
|
41
|
+
def all_contexts
|
42
|
+
Dir[File.expand_path('../contexts/*.rb', File.dirname(__FILE__))].each do |fcheck|
|
43
|
+
run_context(fcheck)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_context(filename)
|
48
|
+
@run_context = {}
|
49
|
+
self.instance_eval(IO.read(filename), filename, 1)
|
50
|
+
if @run_context[:context]
|
51
|
+
data[@run_context[:context][:key]] = Hashie::Mash.new @run_context[:context][:val]
|
52
|
+
else
|
53
|
+
warn "No real data fetched. Watch output for errors."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/es-diag/version.rb
CHANGED
data/resources/screen.png
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es-diag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hashie
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
description: Elastic Search diagnostics tool
|
47
63
|
email:
|
48
64
|
- jondotan@gmail.com
|
@@ -57,10 +73,13 @@ files:
|
|
57
73
|
- Rakefile
|
58
74
|
- bin/es-diag
|
59
75
|
- es-diag.gemspec
|
76
|
+
- lib/checks/local_node_jvm_heap.rb
|
60
77
|
- lib/checks/ulimits.rb
|
78
|
+
- lib/contexts/es_local_node.rb
|
61
79
|
- lib/es-diag.rb
|
62
80
|
- lib/es-diag/check.rb
|
63
81
|
- lib/es-diag/cli.rb
|
82
|
+
- lib/es-diag/context.rb
|
64
83
|
- lib/es-diag/version.rb
|
65
84
|
- lib/ohai_plugins/ulimit.rb
|
66
85
|
- resources/screen.png
|