logstash-input-jmx 0.1.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/NOTICE.TXT +5 -0
- data/README.md +5 -5
- data/lib/logstash/inputs/jmx.rb +19 -2
- data/logstash-input-jmx.gemspec +3 -3
- data/spec/inputs/jmx_spec.rb +74 -0
- metadata +23 -23
- data/.gitignore +0 -4
- data/Rakefile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb0381af11cf452bd3d7bb53ac8cc4ef0b2a2903
|
4
|
+
data.tar.gz: 09acbb74bd4d7b8090c631f673b1640a8b48cdf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1402c93ba0da3e1c34bbce409f6ac9c97a139863d5434b50a23aca259ae04229913314d05c5208bd73a03abd03d9e2c8e2e75e69e9cde4725de68c9d1d99bf29
|
7
|
+
data.tar.gz: fcb04004db853801d769185dcd00e76d70667376f8024988c5859848e3d879ea29843737ad4a64bfa4a9ca82bf22f37bd55b4bc365b104deb6062da5637ddb13
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
3
|
+
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
4
|
+
- Dependency on logstash-core update to 2.0
|
5
|
+
|
data/NOTICE.TXT
ADDED
data/README.md
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
4
|
|
5
5
|
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
6
|
|
7
7
|
## Documentation
|
8
8
|
|
9
|
-
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.
|
9
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
10
10
|
|
11
11
|
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
-
- For more asciidoc formatting tips, see the excellent reference here https://github.com/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
16
|
-
Need help? Try #logstash on freenode IRC or the logstash
|
16
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
17
|
|
18
18
|
## Developing
|
19
19
|
|
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
83
|
|
84
84
|
It is more important to the community that you are able to contribute.
|
85
85
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/lib/logstash/inputs/jmx.rb
CHANGED
@@ -191,6 +191,7 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
191
191
|
event['metric_path'] = metric_path_substituted
|
192
192
|
event['metric_value_string'] = metric_value.to_s
|
193
193
|
end
|
194
|
+
decorate(event)
|
194
195
|
queue << event
|
195
196
|
end
|
196
197
|
|
@@ -208,12 +209,14 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
208
209
|
@logger.debug("Connect to #{thread_hash_conf['host']}:#{thread_hash_conf['port']} with user #{thread_hash_conf['username']}")
|
209
210
|
jmx_connection = JMX::MBean.connection :host => thread_hash_conf['host'],
|
210
211
|
:port => thread_hash_conf['port'],
|
212
|
+
:url => thread_hash_conf['url'],
|
211
213
|
:username => thread_hash_conf['username'],
|
212
214
|
:password => thread_hash_conf['password']
|
213
215
|
else
|
214
216
|
@logger.debug("Connect to #{thread_hash_conf['host']}:#{thread_hash_conf['port']}")
|
215
217
|
jmx_connection = JMX::MBean.connection :host => thread_hash_conf['host'],
|
216
|
-
:port => thread_hash_conf['port']
|
218
|
+
:port => thread_hash_conf['port'],
|
219
|
+
:url => thread_hash_conf['url']
|
217
220
|
end
|
218
221
|
|
219
222
|
|
@@ -288,6 +291,8 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
288
291
|
end
|
289
292
|
end
|
290
293
|
jmx_connection.close
|
294
|
+
rescue LogStash::ShutdownSignal
|
295
|
+
break #free
|
291
296
|
rescue Exception => ex
|
292
297
|
@logger.error(ex.message)
|
293
298
|
@logger.error(ex.backtrace.join("\n"))
|
@@ -316,7 +321,7 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
316
321
|
threads << Thread.new { thread_jmx(@queue_conf,queue) }
|
317
322
|
end
|
318
323
|
|
319
|
-
while
|
324
|
+
while !@interrupted
|
320
325
|
@logger.info("Loading configuration files in path", :path => @path)
|
321
326
|
Dir.foreach(@path) do |item|
|
322
327
|
next if item == '.' or item == '..'
|
@@ -354,9 +359,21 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
354
359
|
\nYou must adapt nb_thread, retrieve_interval to the number of jvm/metrics you want to retrieve.")
|
355
360
|
end
|
356
361
|
end
|
362
|
+
rescue LogStash::ShutdownSignal
|
363
|
+
#exiting
|
357
364
|
rescue Exception => ex
|
358
365
|
@logger.error(ex.message)
|
359
366
|
@logger.error(ex.backtrace.join("\n"))
|
367
|
+
ensure
|
368
|
+
threads.each do |thread|
|
369
|
+
thread.raise(LogStash::ShutdownSignal) if thread.alive?
|
370
|
+
end
|
360
371
|
end
|
372
|
+
|
361
373
|
end
|
374
|
+
|
375
|
+
public
|
376
|
+
def close
|
377
|
+
@interrupted = true
|
378
|
+
end # def close
|
362
379
|
end
|
data/logstash-input-jmx.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-jmx'
|
4
|
-
s.version = '0.1
|
4
|
+
s.version = '2.0.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Retrieve metrics from jmx."
|
7
7
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
14
|
-
s.files =
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
15
|
|
16
16
|
# Tests
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core",
|
23
|
+
s.add_runtime_dependency "logstash-core", ">= 2.0.0.snapshot", "< 3.0.0"
|
24
24
|
|
25
25
|
s.add_runtime_dependency 'jmx4r'
|
26
26
|
|
data/spec/inputs/jmx_spec.rb
CHANGED
@@ -3,6 +3,7 @@ require "logstash/devutils/rspec/spec_helper"
|
|
3
3
|
require "logstash/inputs/jmx"
|
4
4
|
require "logstash/codecs/plain"
|
5
5
|
require 'stud/temporary'
|
6
|
+
require "jmx4r"
|
6
7
|
|
7
8
|
describe LogStash::Inputs::Jmx do
|
8
9
|
|
@@ -79,4 +80,77 @@ describe LogStash::Inputs::Jmx do
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
end
|
83
|
+
|
84
|
+
context "establish JMX connection" do
|
85
|
+
subject { LogStash::Inputs::Jmx.new("path" => jmx_config_path, "nb_thread" => 1, "polling_frequency" => 1)}
|
86
|
+
|
87
|
+
let(:queue) { Queue.new }
|
88
|
+
it "pass host/port connection parameters to jmx4r" do
|
89
|
+
File.open(File.join(jmx_config_path,"my.config.json"), "wb") { |file| file.write(<<-EOT)
|
90
|
+
{
|
91
|
+
"host" : "localhost",
|
92
|
+
"port" : 1234,
|
93
|
+
"queries": []
|
94
|
+
}
|
95
|
+
EOT
|
96
|
+
}
|
97
|
+
|
98
|
+
expect(JMX::MBean).to receive(:connection).with({
|
99
|
+
:host => "localhost",
|
100
|
+
:port => 1234,
|
101
|
+
:url => nil
|
102
|
+
}).and_return(nil)
|
103
|
+
|
104
|
+
subject.register
|
105
|
+
Thread.new(subject) { sleep 0.5; subject.close } # force the plugin to exit
|
106
|
+
subject.run(queue)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "pass custom url in addition of host/port connection parameters to jmx4r" do
|
110
|
+
File.open(File.join(jmx_config_path,"my.config.json"), "wb") { |file| file.write(<<-EOT)
|
111
|
+
{
|
112
|
+
"host" : "localhost",
|
113
|
+
"port" : 1234,
|
114
|
+
"url" : "abcdefg",
|
115
|
+
"queries": []
|
116
|
+
}
|
117
|
+
EOT
|
118
|
+
}
|
119
|
+
|
120
|
+
expect(JMX::MBean).to receive(:connection).with({
|
121
|
+
:host => "localhost",
|
122
|
+
:port => 1234,
|
123
|
+
:url => "abcdefg"
|
124
|
+
}).and_return(nil)
|
125
|
+
|
126
|
+
subject.register
|
127
|
+
Thread.new(subject) { sleep 0.5; subject.close } # force the plugin to exit
|
128
|
+
subject.run(queue)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "pass host/port username/password connection parameters to jmx4r" do
|
132
|
+
File.open(File.join(jmx_config_path,"my.config.json"), "wb") { |file| file.write(<<-EOT)
|
133
|
+
{
|
134
|
+
"host" : "localhost",
|
135
|
+
"port" : 1234,
|
136
|
+
"username" : "me",
|
137
|
+
"password" : "secret",
|
138
|
+
"queries": []
|
139
|
+
}
|
140
|
+
EOT
|
141
|
+
}
|
142
|
+
|
143
|
+
expect(JMX::MBean).to receive(:connection).with({
|
144
|
+
:host => "localhost",
|
145
|
+
:port => 1234,
|
146
|
+
:url => nil,
|
147
|
+
:username => "me",
|
148
|
+
:password => "secret"
|
149
|
+
}).and_return(nil)
|
150
|
+
|
151
|
+
subject.register
|
152
|
+
Thread.new(subject) { sleep 0.5; subject.close } # force the plugin to exit
|
153
|
+
subject.run(queue)
|
154
|
+
end
|
155
|
+
end
|
82
156
|
end
|
metadata
CHANGED
@@ -1,89 +1,89 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-jmx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.0
|
20
|
-
- - <
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0.0
|
23
14
|
requirement: !ruby/object:Gem::Requirement
|
24
15
|
requirements:
|
25
16
|
- - '>='
|
26
17
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
18
|
+
version: 2.0.0.snapshot
|
28
19
|
- - <
|
29
20
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
21
|
+
version: 3.0.0
|
22
|
+
name: logstash-core
|
31
23
|
prerelease: false
|
32
24
|
type: :runtime
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: jmx4r
|
35
25
|
version_requirements: !ruby/object:Gem::Requirement
|
36
26
|
requirements:
|
37
27
|
- - '>='
|
38
28
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
29
|
+
version: 2.0.0.snapshot
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
40
34
|
requirement: !ruby/object:Gem::Requirement
|
41
35
|
requirements:
|
42
36
|
- - '>='
|
43
37
|
- !ruby/object:Gem::Version
|
44
38
|
version: '0'
|
39
|
+
name: jmx4r
|
45
40
|
prerelease: false
|
46
41
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: logstash-devutils
|
49
42
|
version_requirements: !ruby/object:Gem::Requirement
|
50
43
|
requirements:
|
51
44
|
- - '>='
|
52
45
|
- !ruby/object:Gem::Version
|
53
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
55
49
|
requirements:
|
56
50
|
- - '>='
|
57
51
|
- !ruby/object:Gem::Version
|
58
52
|
version: '0'
|
53
|
+
name: logstash-devutils
|
59
54
|
prerelease: false
|
60
55
|
type: :development
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: logstash-codec-plain
|
63
56
|
version_requirements: !ruby/object:Gem::Requirement
|
64
57
|
requirements:
|
65
58
|
- - '>='
|
66
59
|
- !ruby/object:Gem::Version
|
67
60
|
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
68
62
|
requirement: !ruby/object:Gem::Requirement
|
69
63
|
requirements:
|
70
64
|
- - '>='
|
71
65
|
- !ruby/object:Gem::Version
|
72
66
|
version: '0'
|
67
|
+
name: logstash-codec-plain
|
73
68
|
prerelease: false
|
74
69
|
type: :development
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
75
|
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
76
76
|
email: info@elastic.co
|
77
77
|
executables: []
|
78
78
|
extensions: []
|
79
79
|
extra_rdoc_files: []
|
80
80
|
files:
|
81
|
-
- .
|
81
|
+
- CHANGELOG.md
|
82
82
|
- CONTRIBUTORS
|
83
83
|
- Gemfile
|
84
84
|
- LICENSE
|
85
|
+
- NOTICE.TXT
|
85
86
|
- README.md
|
86
|
-
- Rakefile
|
87
87
|
- lib/logstash/inputs/jmx.rb
|
88
88
|
- logstash-input-jmx.gemspec
|
89
89
|
- spec/inputs/jmx_spec.rb
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.8
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Retrieve metrics from jmx.
|
data/.gitignore
DELETED