logstash-input-remote_proc 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c02140e9d9c51731875a6506a1bdd0186c50b5d
4
- data.tar.gz: fcd1d2f715390bba9b4bb71fed8c065d968e5b94
3
+ metadata.gz: 5fca24e5d1158779effdece8b7c0cafcf52f7150
4
+ data.tar.gz: 6c7ca10796ad5786a6c7c53407775dae0b06754f
5
5
  SHA512:
6
- metadata.gz: f36c5471a1bf132ae0ef534c931c241e29e7ac1af2ead1f21a24d1233f8f12d14506cf686fa89349d47c111c86c0af03274e78fac23c75c6e88f913a0df81157
7
- data.tar.gz: d27e517f6d4fbf25c20ece9eb6d8e42978c3c9c8305827593565b376c032013f2edba659b222bce91cd57fd810270a9deb82b173968c813ad4f6d6ca25b2ac92
6
+ metadata.gz: 98e493503bbbf1a5fefc5cc42cc792f0db95f8a18c20e4cf0c77755481a2a0150871908ef692be2685a4775073709999f327a1d5b8b7de59bf1bb37e0f523c97
7
+ data.tar.gz: 2816b99edcc52e08a151197ef2f5c81dabf7ae1f5b8bc588e44554392a6597176d390954e54d57919ee947057d90e12acd70051833c22cf081052cdf40712a62
@@ -134,52 +134,71 @@ module LogStash
134
134
  # we can abort the loop if stop? becomes true
135
135
  until stop?
136
136
  @ssh_sessions.each do |ssh|
137
- ssh.open_channel do |chan|
138
- chan.connection.options[:properties]['_commands'].each do |method, command|
139
- result_data = String.new('')
140
- error_data = String.new('')
137
+ ssh.properties['_commands'].each do |method, command|
138
+ ssh.open_channel do |chan|
141
139
  chan.exec(command) do |ch, success|
142
- next unless success
140
+ ch[:result_data] = String.new('')
141
+ ch[:result_error] = String.new('')
142
+ ch[:result_host] = ssh.properties['host']
143
+ ch[:result_port] = ssh.properties['port']
144
+ unless success
145
+ @logger.warn('CHANNEL_EXEC_UNSUCCESS',
146
+ command: command,
147
+ host: ch[:result_host],
148
+ port: ch[:result_port])
149
+ next
150
+ end
143
151
  # "on_data" called when the process writes to stdout
144
- ch.on_data { |_c, data| result_data << data }
152
+ ch.on_data { |_c, data| ch[:result_data] << data }
153
+ ch.on_process do |_c|
154
+ unless ch[:result_error].empty?
155
+ ch[:result_error].chomp!
156
+ ch[:result_error] = ch[:result_error].force_encoding('UTF-8')
157
+ @logger.warn(ch[:result_error])
158
+ next
159
+ end
160
+ next if ch[:result_data].empty?
161
+ result = send("proc_#{method}",
162
+ ch[:result_data].force_encoding('UTF-8'))
163
+ next if result.empty?
164
+ event = LogStash::Event.new(
165
+ method => result,
166
+ host: @host,
167
+ type: @type || "system-#{method}",
168
+ metric_name: "system-#{method}",
169
+ remote_host: ch[:result_host],
170
+ remote_port: ch[:result_port],
171
+ command: command,
172
+ message: ch[:result_data]
173
+ )
174
+ decorate(event)
175
+ queue << event
176
+ end
177
+ ch.on_open_failed do |c, code, desc|
178
+ @logger.warn('CHANNEL_OPEN_FAILED',
179
+ host: ch[:result_host],
180
+ channel: c,
181
+ code: code,
182
+ description: desc)
183
+ end
145
184
  # "on_extended_data", called when the process writes to stderr
146
- ch.on_extended_data { |_ch, _type, data| error_data << data }
185
+ ch.on_extended_data do |_ch, _type, data|
186
+ ch[:result_error] << data
187
+ end
147
188
  ch.on_close(&:close)
148
189
  end
149
190
  chan.wait
150
- unless error_data.empty?
151
- error_data.chomp!
152
- error_data = error_data.force_encoding('UTF-8')
153
- @logger.warn(error_data)
154
- next
155
- end
156
- next if result_data.empty?
157
- result = send("proc_#{method}",
158
- result_data.force_encoding('UTF-8'))
159
- next if result.empty?
160
- event = LogStash::Event.new(
161
- method => result,
162
- host: @host,
163
- type: @type || "system-#{method}",
164
- metric_name: "system-#{method}",
165
- remote_host: chan.connection.options[:properties]['host'],
166
- remote_port: chan.connection.options[:properties]['port'],
167
- command: command,
168
- message: result_data
169
- )
170
- decorate(event)
171
- queue << event
172
191
  end
173
192
  end
174
- ssh.loop
175
193
  end # @ssh_sessions block
194
+ @ssh_sessions.each(&:loop)
176
195
  Stud.stoppable_sleep(@interval) { stop? }
177
196
  end # until loop
178
197
  end # def run
179
198
 
180
199
  def stop
181
- @ssh_sessions.map(&:close)
182
- @ssh_gateways.map(&:shutdown!) unless @ssh_gateways.empty?
200
+ @ssh_sessions.each(&:close)
201
+ @ssh_gateways.each(&:shutdown!) unless @ssh_gateways.empty?
183
202
  end
184
203
 
185
204
  private
@@ -187,7 +206,7 @@ module LogStash
187
206
  # Return only valide property keys.
188
207
  def prepare_servers!(server)
189
208
  server.select! { |k| SERVER_OPTIONS.include?(k) }
190
- server.merge!(SERVER_OPTIONS) { |_key_, old, _new_| old }
209
+ server.merge!(SERVER_OPTIONS) { |_key, old, _new| old }
191
210
  cmds = if (@proc_list - ['_all']).empty?
192
211
  COMMANDS.dup
193
212
  else
@@ -197,7 +216,8 @@ module LogStash
197
216
  server['_commands'] = cmds.each do |k, v|
198
217
  cmds[k] = v % { system_reader: server['system_reader'],
199
218
  proc_prefix_path: server['proc_prefix_path'] }
200
- end.freeze
219
+ end
220
+ server['_commands'].freeze
201
221
  end
202
222
 
203
223
  # Prepare all server configuration
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-remote_proc'
3
- s.version = '0.1.8'
3
+ s.version = '0.1.9'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'This Logstash plugin collects PROCFS metrics through remote SSH servers.'
6
6
  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'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-remote_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kakesa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-28 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement