estool 0.0.6.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 734b762b75084c2f6aabe764e0366c823ab12c30
4
+ data.tar.gz: 9d0b92d3c3fcf0c001241240f4d76e0d21fc1692
5
+ SHA512:
6
+ metadata.gz: 955f2a559a3ce1d249f16b702642ec228522ecfbab4c4bf279c60b17b80fe1e52817dd0fa667fb4b1ebb07e66671a4eff780c41c05108452e0c32d1162ead312
7
+ data.tar.gz: 9610236bc16ad7038df4dec8341efd458e3d7e5113a2a4811eaa5d15cc14b3b519a700cfe3722de11163e69162b4fa857c838ca89106e2aa1f4da7ff521685ac
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ ESTool - Elasticsearch CLI Tool
2
+
3
+ Copyright (C) 2016 David Hollinger
4
+
5
+ Contact at david.hollinger@moduletux.com
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ https://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ ESTool - Elasticsearch Commandline Tool
2
+ =======================================
3
+
4
+ EStool is a command-line tool for interacting with the Elasticsearch search and analytics engine.
5
+
6
+ Documentation
7
+ -------------
8
+
9
+ Tool is still in development. Only portions of Elasticsearch's [Cat API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html) have been implemented so far.
10
+
11
+ License
12
+ -------
13
+
14
+ See [LICENSE](LICENSE) file.
15
+
16
+ Maintainers
17
+ -----------
18
+ * David Hollinger, david.hollinger@moduletux.com, github:dhollinger
data/bin/estool ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'estool'
3
+
4
+ # Placeholder
5
+ Estool::Cli.start(ARGV)
@@ -0,0 +1,20 @@
1
+ require 'elasticsearch-api'
2
+ require 'estool/connections'
3
+
4
+ module Estool::Actions
5
+ class Cat
6
+ def self.run(action, data, options)
7
+ client = Estool::Connections.start_conn(options[:host], options[:port])
8
+ Estool::Connections.test_conn(client)
9
+ begin
10
+ puts client.cat.send(action, data)
11
+ rescue ArgumentError => args
12
+ puts "
13
+ #{args}
14
+ Usage: 'estool cat help #{action}' for more information
15
+ "
16
+ exit 1
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Aliases
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @timeout = options[:timeout]
10
+ @name = options[:name]
11
+ @server = {
12
+ host: options[:host],
13
+ port: options[:port]
14
+ }
15
+ end
16
+
17
+ def run
18
+ data = {
19
+ v: @verbose,
20
+ format: @output,
21
+ master_timeout: @timeout,
22
+ name: @name
23
+ }
24
+ Estool::Actions::Cat.run(:aliases, data, @server)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Allocation
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @node = options[:node]
9
+ @bytes = options[:bytes]
10
+ @output = options[:output]
11
+ @server = {
12
+ host: options[:host],
13
+ port: options[:port]
14
+ }
15
+ end
16
+
17
+ def run
18
+ data = {
19
+ v: @verbose,
20
+ node_id: @node,
21
+ bytes: @bytes,
22
+ format: @output
23
+ }
24
+ Estool::Actions::Cat.run(:allocation, data, @server)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Count
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @timeout = options[:timeout]
10
+ @index = options[:index]
11
+ @server = {
12
+ host: options[:host],
13
+ port: options[:port]
14
+ }
15
+ end
16
+
17
+ def run
18
+ data = {
19
+ v: @verbose,
20
+ format: @output,
21
+ master_timeout: @timeout,
22
+ index: @index
23
+ }
24
+ Estool::Actions::Cat.run(:count, data, @server)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Fielddata
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @timeout = options[:timeout]
9
+ @bytes = options[:bytes]
10
+ @fields = options[:fields]
11
+ @server = {
12
+ host: options[:host],
13
+ port: options[:port]
14
+ }
15
+ end
16
+
17
+ def run
18
+ data = {
19
+ v: @verbose,
20
+ master_timeout: @timeout,
21
+ bytes: @bytes
22
+ }
23
+ data[:fields] = @fields unless @fields.nil?
24
+ Estool::Actions::Cat.run(:fielddata, data, @server)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Health
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @timeout = options[:timeout]
10
+ @server = {
11
+ host: options[:host],
12
+ port: options[:port]
13
+ }
14
+ end
15
+
16
+ def run
17
+ data = {
18
+ v: @verbose,
19
+ format: @output,
20
+ master_timeout: @timeout
21
+ }
22
+ Estool::Actions::Cat.run(:health, data, @server)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Indices
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @bytes = options[:bytes]
9
+ @primary = options[:primary]
10
+ @output = options[:output]
11
+ @index = options[:index]
12
+ @server = {
13
+ host: options[:host],
14
+ port: options[:port]
15
+ }
16
+ end
17
+
18
+ def run
19
+ data = {
20
+ v: @verbose,
21
+ bytes: @bytes,
22
+ pri: @primary,
23
+ format: @output
24
+ }
25
+ data[:index] = @index unless @index.nil?
26
+ Estool::Actions::Cat.run(:indices, data, @server)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Master
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @server = {
10
+ host: options[:host],
11
+ port: options[:port]
12
+ }
13
+ end
14
+
15
+ def run
16
+ data = {
17
+ v: @verbose,
18
+ format: @output
19
+ }
20
+ Estool::Actions::Cat.run(:master, data, @server)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Nodeattrs
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @server = {
10
+ host: options[:host],
11
+ port: options[:port]
12
+ }
13
+ end
14
+
15
+ def run
16
+ data = {
17
+ v: @verbose,
18
+ format: @output
19
+ }
20
+ Estool::Actions::Cat.run(:nodeattrs, data, @server)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Nodes
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @server = {
10
+ host: options[:host],
11
+ port: options[:port]
12
+ }
13
+ end
14
+
15
+ def run
16
+ data = {
17
+ v: @verbose,
18
+ format: @output
19
+ }
20
+ Estool::Actions::Cat.run(:nodes, data, @server)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Plugin
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @server = {
9
+ host: options[:host],
10
+ port: options[:port]
11
+ }
12
+ end
13
+
14
+ def run
15
+ data = {
16
+ v: @verbose
17
+ }
18
+ Estool::Actions::Cat.run(:plugins, data, @server)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Ptasks
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @output = options[:output]
9
+ @server = {
10
+ host: options[:host],
11
+ port: options[:port]
12
+ }
13
+ end
14
+
15
+ def run
16
+ data = {
17
+ v: @verbose,
18
+ format: @output,
19
+ }
20
+ Estool::Actions::Cat.run(:pending_tasks, data, @server)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Recovery
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @bytes = options[:bytes]
9
+ @index = options[:index]
10
+ @output = options[:output]
11
+ @server = {
12
+ host: options[:host],
13
+ port: options[:port]
14
+ }
15
+ end
16
+
17
+ def run
18
+ data = {
19
+ v: @verbose,
20
+ format: @output,
21
+ }
22
+ data[:index] = @index unless @index.nil?
23
+ data[:bytes] = @bytes unless @bytes.nil?
24
+ Estool::Actions::Cat.run(:recovery, data, @server)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ require 'estool/actions/cat'
2
+
3
+ module Estool
4
+ class Cat::Repositories
5
+
6
+ def initialize(options)
7
+ @verbose = options[:verbose]
8
+ @server = {
9
+ host: options[:host],
10
+ port: options[:port]
11
+ }
12
+ end
13
+
14
+ def run
15
+ data = {
16
+ v: @verbose
17
+ }
18
+ Estool::Actions::Cat.run(:repositories, data, @server)
19
+ end
20
+ end
21
+ end
data/lib/estool/cat.rb ADDED
@@ -0,0 +1,146 @@
1
+ require 'thor'
2
+
3
+ module Estool
4
+ class Cat < Thor
5
+ class_option 'host', :type => :string,
6
+ :banner => 'Elasticsearch host to connect to',
7
+ :default => 'localhost',
8
+ :aliases => '-H'
9
+ class_option 'port', :type => :string,
10
+ :banner => 'Port to use when connecting to Elasticsearch',
11
+ :default => '9200',
12
+ :aliases => '-p'
13
+ class_option 'verbose', :type => :boolean,
14
+ :banner => 'Verbose option. Not all subcommands support it',
15
+ :default => false,
16
+ :aliases => '-v'
17
+ class_option 'output', :type => :string,
18
+ :banner => 'Display output as json or text',
19
+ :default => 'text',
20
+ :aliases => '-o'
21
+ class_option 'timeout', :type => :numeric,
22
+ :banner => 'Set Master Timeout in seconds',
23
+ :default => 30,
24
+ :aliases => '-t'
25
+
26
+ desc 'aliases [OPTIONS]', 'Display information about aliases'
27
+ method_option 'name', :type => :string,
28
+ :banner => 'Name of alias(es) to display information about',
29
+ :aliases => '-n'
30
+ def aliases
31
+ require 'estool/cat/aliases'
32
+ Aliases.new(options).run
33
+ end
34
+
35
+ desc 'allocation [OPTIONS]', 'Display shard allocation information'
36
+ method_option 'node', :type => :array,
37
+ :banner => 'Comma separated list of nodes',
38
+ :aliases => '-n'
39
+ method_option 'bytes', :type => :string,
40
+ :banner => 'Unit to display byte values in.',
41
+ :default => 'b',
42
+ :enum => %w{b k m g},
43
+ :aliases => '-b'
44
+ def allocation
45
+ require 'estool/cat/allocation'
46
+ Allocation.new(options).run
47
+ end
48
+
49
+ desc 'count [OPTIONS]', 'Return Document count for cluster or indices'
50
+ method_option 'index', :type => :string,
51
+ :banner => 'Index to count documents',
52
+ :aliases => '-i'
53
+ def count
54
+ require 'estool/cat/count'
55
+ Count.new(options).run
56
+ end
57
+
58
+ desc 'fielddata [OPTIONS]', 'Return field data usage data'
59
+ method_option 'fields', :type => :string,
60
+ :banner => 'Comma separated list of fields',
61
+ :aliases => '-f'
62
+ method_option 'bytes', :type => :string,
63
+ :banner => 'Unit to display byte values in.',
64
+ :default => 'b',
65
+ :enum => %w{b k m g},
66
+ :aliases => '-b'
67
+ def fielddata
68
+ require 'estool/cat/fielddata'
69
+ Fielddata.new(options).run
70
+ end
71
+
72
+ desc 'health [OPTIONS]', 'Display Elasticsearch Cluster health'
73
+ def health
74
+ require 'estool/cat/health'
75
+ Health.new(options).run
76
+ end
77
+
78
+ desc 'indices [OPTIONS]', 'Display indices statistics across the cluster'
79
+ method_option 'index', :type => :string,
80
+ :banner => 'Comma separated list of index names to display',
81
+ :aliases => '-i'
82
+ method_option 'primary', :type => :boolean,
83
+ :banner => 'Limit returned information to primary shards only',
84
+ :aliases => '-P',
85
+ :default => false
86
+ method_option 'bytes', :type => :string,
87
+ :banner => 'Unit to display byte values in.',
88
+ :default => 'b',
89
+ :enum => %w{b k m g},
90
+ :aliases => '-b'
91
+ def indices
92
+ require 'estool/cat/indices'
93
+ Indices.new(options).run
94
+ end
95
+
96
+ desc 'master [OPTIONS]', 'Display current master node'
97
+ def master
98
+ require 'estool/cat/master'
99
+ Master.new(options).run
100
+ end
101
+
102
+ desc 'nodeattrs [OPTIONS]', 'Display custom node attributes'
103
+ def nodeattrs
104
+ require 'estool/cat/nodeattrs'
105
+ Nodeattrs.new(options).run
106
+ end
107
+
108
+ desc 'nodes [OPTIONS]', 'Display Elasticsearch Nodes'
109
+ def nodes
110
+ require 'estool/cat/nodes'
111
+ Nodes.new(options).run
112
+ end
113
+
114
+ desc 'ptasks [OPTIONS]', 'Display Elasticsearch Pending Task in tabular format'
115
+ def ptasks
116
+ require 'estool/cat/ptasks'
117
+ Ptasks.new(options).run
118
+ end
119
+
120
+ desc 'plugins [OPTIONS]', 'Display Elasticsearch Plugins'
121
+ def plugins
122
+ require 'estool/cat/plugin'
123
+ Plugin.new(options).run
124
+ end
125
+
126
+ desc 'recovery [OPTIONS]', 'Display shard recovery status'
127
+ method_option 'index', :type => :string,
128
+ :banner => 'List of indexes to return information about. Comma-separated',
129
+ :aliases => '-i'
130
+ method_option 'bytes', :type => :string,
131
+ :banner => 'Unit to display byte values in.',
132
+ :default => 'b',
133
+ :enum => %w{b k m g},
134
+ :aliases => '-b'
135
+ def recovery
136
+ require 'estool/cat/recovery'
137
+ Recovery.new(options).run
138
+ end
139
+
140
+ desc 'repositories [OPTIONS]', 'Display registered repositories'
141
+ def repositories
142
+ require 'estool/cat/repositories'
143
+ Repositories.new(options).run
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,21 @@
1
+ require 'elasticsearch'
2
+ require 'net/http'
3
+
4
+ module Estool
5
+ module Connections
6
+
7
+ def self.start_conn(host,port)
8
+ Elasticsearch::Client.new host: "#{host}:#{port}"
9
+ end
10
+
11
+ def self.test_conn(client)
12
+ begin
13
+ client.perform_request 'GET', '_cluster/health'
14
+ rescue Faraday::ConnectionFailed => connfail
15
+ # Connection Failure Message
16
+ puts connfail
17
+ exit 1
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module Estool
2
+ ESTOOL_ROOT = File.expand_path("../..", __FILE__)
3
+ VERSION = "0.0.6-alpha"
4
+ end
data/lib/estool.rb ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ require 'elasticsearch'
3
+ require 'net/http'
4
+ require 'optparse'
5
+ require 'estool/cat'
6
+ require 'estool/connections'
7
+ require 'thor'
8
+
9
+ module Estool
10
+ class Cli < Thor
11
+ register(Estool::Cat, 'cat', 'cat [SUBCOMMAND] [OPTIONS]', 'Utilize Elasticsearch API', )
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: estool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6.pre.alpha
5
+ platform: ruby
6
+ authors:
7
+ - David Hollinger III
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: elasticsearch-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.17
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.17
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: thor
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description:
48
+ email:
49
+ - david.hollinger@moduletux.com
50
+ executables:
51
+ - estool
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - LICENSE
56
+ - README.md
57
+ - bin/estool
58
+ - lib/estool.rb
59
+ - lib/estool/actions/cat.rb
60
+ - lib/estool/cat.rb
61
+ - lib/estool/cat/aliases.rb
62
+ - lib/estool/cat/allocation.rb
63
+ - lib/estool/cat/count.rb
64
+ - lib/estool/cat/fielddata.rb
65
+ - lib/estool/cat/health.rb
66
+ - lib/estool/cat/indices.rb
67
+ - lib/estool/cat/master.rb
68
+ - lib/estool/cat/nodeattrs.rb
69
+ - lib/estool/cat/nodes.rb
70
+ - lib/estool/cat/plugin.rb
71
+ - lib/estool/cat/ptasks.rb
72
+ - lib/estool/cat/recovery.rb
73
+ - lib/estool/cat/repositories.rb
74
+ - lib/estool/connections.rb
75
+ - lib/estool/version.rb
76
+ homepage: https://github.com/dhollinger/estool
77
+ licenses:
78
+ - Apache-2.0
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">"
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.1
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.5.1
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Command Line tool for interacting with Elasticsearch
100
+ test_files: []
101
+ has_rdoc: