logstash-output-exec 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -2
- data/lib/logstash/outputs/exec.rb +23 -5
- data/logstash-output-exec.gemspec +2 -2
- data/spec/outputs/exec_spec.rb +47 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de991ebd043dcba69a36d370a66ec776ec431bc5
|
4
|
+
data.tar.gz: e7377aa117439b77a95a72c0ce64713635fb2619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c1c09d96af06902190344f75e964c67abaea4172f4b1c7edd2e89fa62f7f7cb03b4db45a3bc58a83b690a234505159430055d082119fd9dfe4ed91ee95dbe18
|
7
|
+
data.tar.gz: 6fa544d93d63d0264db98a67e14a8e65099dcaff9ce7bba153d8b41a453b81837c5b77fe0793c4ccfea7ea4527c930f1573de0ecdf49838dd928efabb71ec696
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,21 @@
|
|
1
|
+
## 3.0.2
|
2
|
+
- Replace `Kernel.system` with `Open3.open3` and fixes `ThreadDeath` issues
|
3
|
+
- Will now log stdout and stderr of the command when running logstash in debug mode, the response is streamed to the log.
|
4
|
+
- Added a `quiet` option to not print the result of the command to stdout, this option is on by default for backward compatibility
|
5
|
+
- Added tests
|
6
|
+
|
1
7
|
## 3.0.1
|
2
8
|
- Republish all the gems under jruby.
|
9
|
+
|
3
10
|
## 3.0.0
|
4
11
|
- Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
|
5
|
-
|
12
|
+
|
13
|
+
## 2.0.4
|
6
14
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
7
|
-
|
15
|
+
|
16
|
+
## 2.0.3
|
8
17
|
- New dependency requirements for logstash-core for the 5.0 release
|
18
|
+
|
9
19
|
## 2.0.0
|
10
20
|
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
11
21
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/namespace"
|
3
3
|
require "logstash/outputs/base"
|
4
|
+
require "open3"
|
4
5
|
|
5
6
|
# The exec output will run a command for each event received. Ruby's
|
6
7
|
# `system()` function will be used, i.e. the command string will
|
@@ -34,16 +35,33 @@ class LogStash::Outputs::Exec < LogStash::Outputs::Base
|
|
34
35
|
# dynamic strings.
|
35
36
|
config :command, :validate => :string, :required => true
|
36
37
|
|
38
|
+
# display the result of the command to the terminal
|
39
|
+
config :quiet, :validate => :boolean, :default => false
|
40
|
+
|
37
41
|
public
|
38
42
|
def register
|
39
43
|
@logger.debug("exec output registered", :config => @config)
|
40
|
-
end
|
44
|
+
end
|
41
45
|
|
42
46
|
public
|
43
47
|
def receive(event)
|
44
|
-
|
45
|
-
@logger.debug("running exec command", :command =>
|
46
|
-
|
47
|
-
|
48
|
+
cmd = event.sprintf(@command)
|
49
|
+
@logger.debug("running exec command", :command => cmd)
|
50
|
+
|
51
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr|
|
52
|
+
if @logger.debug?
|
53
|
+
@logger.pipe(stdout => :debug, stderr => :debug)
|
54
|
+
else
|
55
|
+
# This is for backward compatibility,
|
56
|
+
# the previous implementation was using `Kernel#system' and the default behavior
|
57
|
+
# of this method is to output the result to the terminal.
|
58
|
+
@logger.terminal(stdout.read.chomp) unless quiet?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
48
62
|
|
63
|
+
private
|
64
|
+
def quiet?
|
65
|
+
@quiet
|
66
|
+
end
|
49
67
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
|
3
2
|
s.name = 'logstash-output-exec'
|
4
|
-
s.version = '3.0.
|
3
|
+
s.version = '3.0.2'
|
5
4
|
s.licenses = ['Apache License (2.0)']
|
6
5
|
s.summary = "This output will run a command for any matching event."
|
7
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"
|
@@ -23,5 +22,6 @@ Gem::Specification.new do |s|
|
|
23
22
|
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
24
23
|
|
25
24
|
s.add_development_dependency 'logstash-devutils'
|
25
|
+
s.add_development_dependency "logstash-codec-plain"
|
26
26
|
end
|
27
27
|
|
data/spec/outputs/exec_spec.rb
CHANGED
@@ -1 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/outputs/exec"
|
3
|
+
require "logstash/event"
|
1
4
|
require "logstash/devutils/rspec/spec_helper"
|
5
|
+
require "tempfile"
|
6
|
+
|
7
|
+
describe LogStash::Outputs::Exec do
|
8
|
+
let(:event) { LogStash::Event.new({ "params" => "1234" }) }
|
9
|
+
let(:output) { "1" }
|
10
|
+
let(:command) { "echo #{output}" }
|
11
|
+
|
12
|
+
let(:config) do
|
13
|
+
{ "command" => command }
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:error_message) { "Oulala" }
|
17
|
+
let(:stderr) { Tempfile.new(error_message) }
|
18
|
+
let(:stdout) { Tempfile.new(output) }
|
19
|
+
let(:stdin) { Tempfile.new("") }
|
20
|
+
|
21
|
+
subject { described_class.new(config) }
|
22
|
+
|
23
|
+
it "receive a command and execute it" do
|
24
|
+
expect(Open3).to receive(:popen3).with(command)
|
25
|
+
subject.receive(event)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when debugging" do
|
29
|
+
before :each do
|
30
|
+
allow(subject.logger).to receive(:debug?).and_return(true)
|
31
|
+
expect(Open3).to receive(:popen3).with(command).and_yield(stdin, stdout, stderr)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "register the stdout and stderr to the logger" do
|
35
|
+
expect(subject.logger).to receive(:pipe).with(stdout => :debug, stderr => :debug)
|
36
|
+
subject.receive(event)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "When debugging is off" do
|
41
|
+
context "when quiet is off" do
|
42
|
+
it "write output to the terminal" do
|
43
|
+
expect(subject.logger).to receive(:terminal).with(output)
|
44
|
+
subject.receive(event)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-exec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: logstash-codec-plain
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
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
|
42
56
|
email: info@elastic.co
|
43
57
|
executables: []
|