logstash-input-jmx 3.0.6 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/inputs/jmx.rb +21 -16
- data/logstash-input-jmx.gemspec +1 -1
- data/spec/inputs/jmx_spec.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c53771abfa6de01498a61244afba4617cc15f2b018c6049ec11fb4e9337b5b9c
|
4
|
+
data.tar.gz: 333a64bfec48374fb106d44967017081a18a091469eb2a39ee80e1cf943f86f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 367ab754640b80f64eab341adcdd6391354f1f851acf7bb3d235f3dcd6c9a96179905a994b577f39d909d6cd7c0588f98549003c1cea98084c1d1b23c2c4722c
|
7
|
+
data.tar.gz: 5ef2eba33289c66cf37a2685aa70130455b1b5da59a11d20b6c3fdf7421b7d0be5e3ccd5d27bc218f51c71b2f2f4c8d178c82bf37ef86cd41d67067e9cc8275f
|
data/CHANGELOG.md
CHANGED
data/lib/logstash/inputs/jmx.rb
CHANGED
@@ -202,7 +202,14 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
202
202
|
begin
|
203
203
|
@logger.debug('Wait config to retrieve from queue conf')
|
204
204
|
thread_hash_conf = queue_conf.pop
|
205
|
-
|
205
|
+
|
206
|
+
if thread_hash_conf == :END
|
207
|
+
# the :END symbol is a signal to terminate the thread
|
208
|
+
@logger.debug? && @logger.debug("Received jmx thread termination signal")
|
209
|
+
return
|
210
|
+
else
|
211
|
+
@logger.debug? && @logger.debug("Retrieve config #{thread_hash_conf} from queue conf")
|
212
|
+
end
|
206
213
|
|
207
214
|
@logger.debug('Check if jmx connection need a user/password')
|
208
215
|
if thread_hash_conf.has_key?('username') and thread_hash_conf.has_key?('password')
|
@@ -213,12 +220,16 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
213
220
|
:username => thread_hash_conf['username'],
|
214
221
|
:password => thread_hash_conf['password']
|
215
222
|
else
|
216
|
-
@logger.debug("Connect to #{thread_hash_conf['host']}:#{thread_hash_conf['port']}")
|
223
|
+
@logger.debug("Connect to #{thread_hash_conf['host']}:#{thread_hash_conf['port']}:#{thread_hash_conf['url']}")
|
217
224
|
jmx_connection = JMX::MBean.connection :host => thread_hash_conf['host'],
|
218
225
|
:port => thread_hash_conf['port'],
|
219
226
|
:url => thread_hash_conf['url']
|
220
227
|
end
|
221
228
|
|
229
|
+
if jmx_connection.nil?
|
230
|
+
@logger.warn("Invalid nil jmx connection, ignoring", :host => thread_hash_conf['host'], :port => thread_hash_conf['port'], :url => thread_hash_conf['url'])
|
231
|
+
next
|
232
|
+
end
|
222
233
|
|
223
234
|
if thread_hash_conf.has_key?('alias')
|
224
235
|
@logger.debug("Set base_metric_path to alias: #{thread_hash_conf['alias']}")
|
@@ -291,8 +302,6 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
291
302
|
end
|
292
303
|
end
|
293
304
|
jmx_connection.close
|
294
|
-
rescue LogStash::ShutdownSignal
|
295
|
-
break #free
|
296
305
|
rescue Exception => ex
|
297
306
|
@logger.error(ex.message)
|
298
307
|
@logger.error(ex.backtrace.join("\n"))
|
@@ -321,7 +330,7 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
321
330
|
threads << Thread.new { thread_jmx(@queue_conf,queue) }
|
322
331
|
end
|
323
332
|
|
324
|
-
while
|
333
|
+
while !stop?
|
325
334
|
@logger.info("Loading configuration files in path", :path => @path)
|
326
335
|
Dir.foreach(@path) do |item|
|
327
336
|
next if item == '.' or item == '..'
|
@@ -343,6 +352,7 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
343
352
|
:exception => ex.message, :backtrace => ex.backtrace)
|
344
353
|
end
|
345
354
|
end
|
355
|
+
|
346
356
|
@logger.debug('Wait until the queue conf is empty')
|
347
357
|
delta=0
|
348
358
|
until @queue_conf.empty?
|
@@ -350,30 +360,25 @@ class LogStash::Inputs::Jmx < LogStash::Inputs::Base
|
|
350
360
|
delta=delta+1
|
351
361
|
sleep(1)
|
352
362
|
end
|
363
|
+
|
353
364
|
wait_time=@polling_frequency-delta
|
354
365
|
if wait_time>0
|
355
366
|
@logger.debug("Wait #{wait_time}s (#{@polling_frequency}-#{delta}(seconds wait until queue conf empty)) before to launch again a new jmx metrics collection")
|
356
|
-
|
367
|
+
Stud.stoppable_sleep(wait_time) { stop? }
|
357
368
|
else
|
358
369
|
@logger.warn("The time taken to retrieve metrics is more important than the retrieve_interval time set.
|
359
370
|
\nYou must adapt nb_thread, retrieve_interval to the number of jvm/metrics you want to retrieve.")
|
360
371
|
end
|
361
372
|
end
|
362
|
-
rescue LogStash::ShutdownSignal
|
363
|
-
#exiting
|
364
373
|
rescue Exception => ex
|
365
374
|
@logger.error(ex.message)
|
366
375
|
@logger.error(ex.backtrace.join("\n"))
|
367
376
|
ensure
|
368
|
-
|
369
|
-
|
377
|
+
@nb_thread.times do |i|
|
378
|
+
@logger.debug? && @logger.debug("Signaling termination to jmx thread #{i + 1}")
|
379
|
+
@queue_conf << :END
|
370
380
|
end
|
381
|
+
threads.each {|t| t.join }
|
371
382
|
end
|
372
|
-
|
373
383
|
end
|
374
|
-
|
375
|
-
public
|
376
|
-
def close
|
377
|
-
@interrupted = true
|
378
|
-
end # def close
|
379
384
|
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 = '3.0.
|
4
|
+
s.version = '3.0.7'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Retrieves metrics from remote Java applications over 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/logstash-plugin install gemname. This gem is not a stand-alone program"
|
data/spec/inputs/jmx_spec.rb
CHANGED
@@ -12,6 +12,10 @@ describe LogStash::Inputs::Jmx do
|
|
12
12
|
FileUtils.remove_dir(jmx_config_path)
|
13
13
|
end
|
14
14
|
|
15
|
+
it_behaves_like "an interruptible input plugin" do
|
16
|
+
let(:config) {{"path" => jmx_config_path, "nb_thread" => 1, "polling_frequency" => 1}}
|
17
|
+
end
|
18
|
+
|
15
19
|
subject { LogStash::Inputs::Jmx.new("path" => jmx_config_path)}
|
16
20
|
|
17
21
|
context "#validate_configuration(conf_hash)" do
|
@@ -83,6 +87,7 @@ describe LogStash::Inputs::Jmx do
|
|
83
87
|
subject { LogStash::Inputs::Jmx.new("path" => jmx_config_path, "nb_thread" => 1, "polling_frequency" => 1)}
|
84
88
|
|
85
89
|
let(:queue) { Queue.new }
|
90
|
+
|
86
91
|
it "pass host/port connection parameters to jmx4r" do
|
87
92
|
File.open(File.join(jmx_config_path,"my.config.json"), "wb") { |file| file.write(<<-EOT)
|
88
93
|
{
|
@@ -100,7 +105,7 @@ describe LogStash::Inputs::Jmx do
|
|
100
105
|
}).and_return(nil)
|
101
106
|
|
102
107
|
subject.register
|
103
|
-
Thread.new(subject) { sleep 0.5; subject.
|
108
|
+
Thread.new(subject) { sleep 0.5; subject.do_stop } # force the plugin to exit
|
104
109
|
subject.run(queue)
|
105
110
|
end
|
106
111
|
|
@@ -122,7 +127,7 @@ describe LogStash::Inputs::Jmx do
|
|
122
127
|
}).and_return(nil)
|
123
128
|
|
124
129
|
subject.register
|
125
|
-
Thread.new(subject) { sleep 0.5; subject.
|
130
|
+
Thread.new(subject) { sleep 0.5; subject.do_stop } # force the plugin to exit
|
126
131
|
subject.run(queue)
|
127
132
|
end
|
128
133
|
|
@@ -147,7 +152,7 @@ describe LogStash::Inputs::Jmx do
|
|
147
152
|
}).and_return(nil)
|
148
153
|
|
149
154
|
subject.register
|
150
|
-
Thread.new(subject) { sleep 0.5; subject.
|
155
|
+
Thread.new(subject) { sleep 0.5; subject.do_stop } # force the plugin to exit
|
151
156
|
subject.run(queue)
|
152
157
|
end
|
153
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-jmx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|