logstash-input-pipe 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/logstash/inputs/pipe.rb +7 -10
- data/logstash-input-pipe.gemspec +4 -4
- data/spec/inputs/pipe_spec.rb +45 -18
- metadata +27 -21
- 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: 9c11181e67feca984d004877b6958667cc79f302
|
4
|
+
data.tar.gz: 37d6a9bbcd4411d7880977594de3eb8ee84429e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e1b1aca0ce72438625a374dc171f656c40b453a00389e3bcbfa70a568549322d02bf62c46b11adef8825b5b331fb6c8f98e5c031217d22d8a39e14bb86c5e8
|
7
|
+
data.tar.gz: 12f4fe9f83be96ec309dbad3bbdbb7f87a923435cde82683dd5684fbf507aabf93286925a249e5f35c35d9aff934b174d215be17b4739444d9c5c094bc33f4a1
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
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
|
|
@@ -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/pipe.rb
CHANGED
@@ -6,6 +6,7 @@ end
|
|
6
6
|
require "logstash/inputs/base"
|
7
7
|
require "logstash/namespace"
|
8
8
|
require "socket" # for Socket.gethostname
|
9
|
+
require "stud/interval"
|
9
10
|
|
10
11
|
# Stream events from a long running command pipe.
|
11
12
|
#
|
@@ -28,7 +29,6 @@ class LogStash::Inputs::Pipe < LogStash::Inputs::Base
|
|
28
29
|
|
29
30
|
def initialize(params)
|
30
31
|
super
|
31
|
-
@shutdown_requested = false
|
32
32
|
@pipe = nil
|
33
33
|
end # def initialize
|
34
34
|
|
@@ -39,9 +39,9 @@ class LogStash::Inputs::Pipe < LogStash::Inputs::Base
|
|
39
39
|
|
40
40
|
public
|
41
41
|
def run(queue)
|
42
|
-
while
|
42
|
+
while !stop?
|
43
43
|
begin
|
44
|
-
@pipe = IO.popen(@command,
|
44
|
+
@pipe = IO.popen(@command, "r")
|
45
45
|
hostname = Socket.gethostname
|
46
46
|
|
47
47
|
@pipe.each do |line|
|
@@ -56,25 +56,22 @@ class LogStash::Inputs::Pipe < LogStash::Inputs::Base
|
|
56
56
|
end
|
57
57
|
@pipe.close
|
58
58
|
@pipe = nil
|
59
|
-
rescue LogStash::ShutdownSignal => e
|
60
|
-
break
|
61
59
|
rescue Exception => e
|
62
60
|
@logger.error("Exception while running command", :e => e, :backtrace => e.backtrace)
|
63
61
|
end
|
64
62
|
|
65
63
|
# Keep running the command forever.
|
66
|
-
|
64
|
+
Stud.stoppable_sleep(10) do
|
65
|
+
stop?
|
66
|
+
end
|
67
67
|
end
|
68
68
|
end # def run
|
69
69
|
|
70
|
-
def
|
71
|
-
@shutdown_requested = true
|
70
|
+
def stop
|
72
71
|
if @pipe
|
73
72
|
Process.kill("KILL", @pipe.pid) rescue nil
|
74
73
|
@pipe.close rescue nil
|
75
74
|
@pipe = nil
|
76
75
|
end
|
77
|
-
finished
|
78
76
|
end
|
79
|
-
|
80
77
|
end # class LogStash::Inputs::Pipe
|
data/logstash-input-pipe.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-pipe'
|
4
|
-
s.version = '
|
4
|
+
s.version = '2.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Stream events from a long running command pipe"
|
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,8 +20,8 @@ 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",
|
24
|
-
|
23
|
+
s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
|
24
|
+
s.add_runtime_dependency 'stud', '~> 0.0.22'
|
25
25
|
s.add_runtime_dependency 'logstash-codec-plain'
|
26
26
|
s.add_development_dependency 'logstash-devutils'
|
27
27
|
end
|
data/spec/inputs/pipe_spec.rb
CHANGED
@@ -1,43 +1,68 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/inputs/pipe"
|
3
4
|
require "tempfile"
|
4
5
|
|
5
|
-
describe
|
6
|
+
describe LogStash::Inputs::Pipe, :unix => true do
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
it "should register" do
|
9
|
+
input = LogStash::Plugin.lookup("input", "pipe").new("command" => "echo 'world'")
|
10
|
+
|
11
|
+
# register will try to load jars and raise if it cannot find jars or if org.apache.log4j.spi.LoggingEvent class is not present
|
12
|
+
expect {input.register}.to_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when interrupting the plugin" do
|
16
|
+
|
17
|
+
it_behaves_like "an interruptible input plugin" do
|
18
|
+
let(:config) { { "command" => "echo ☹" } }
|
19
|
+
end
|
20
|
+
|
21
|
+
it_behaves_like "an interruptible input plugin" do
|
22
|
+
let(:config) { { "command" => "echo foo" } }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "pipe from echo" do
|
28
|
+
|
29
|
+
let(:config) do <<-CONFIG
|
11
30
|
input {
|
12
31
|
pipe {
|
13
32
|
command => "echo ☹"
|
14
33
|
}
|
15
34
|
}
|
16
|
-
|
35
|
+
CONFIG
|
36
|
+
end
|
17
37
|
|
18
|
-
|
38
|
+
let(:event) do
|
39
|
+
input(config) do |pipeline, queue|
|
19
40
|
queue.pop
|
20
41
|
end
|
42
|
+
end
|
21
43
|
|
22
|
-
|
44
|
+
it "should receive the pipe" do
|
45
|
+
expect(event["message"]).to eq("☹")
|
23
46
|
end
|
47
|
+
|
24
48
|
end
|
25
49
|
|
26
|
-
|
27
|
-
5.times.each do
|
28
|
-
it "should pipe from tail -f" do
|
29
|
-
event_count = 10
|
30
|
-
tmp_file = Tempfile.new('logstash-spec-input-pipe')
|
50
|
+
describe "pipe from tail" do
|
31
51
|
|
32
|
-
|
33
|
-
|
52
|
+
let(:tmp_file) { Tempfile.new('logstash-spec-input-pipe') }
|
53
|
+
let(:event_count) { 10 }
|
54
|
+
|
55
|
+
let(:config) do <<-CONFIG
|
56
|
+
input {
|
34
57
|
pipe {
|
35
58
|
command => "tail -n +0 -f #{tmp_file.path}"
|
36
59
|
}
|
37
60
|
}
|
38
|
-
|
61
|
+
CONFIG
|
62
|
+
end
|
39
63
|
|
40
|
-
|
64
|
+
let(:events) do
|
65
|
+
input(config) do |pipeline, queue|
|
41
66
|
File.open(tmp_file, "a") do |fd|
|
42
67
|
event_count.times do |i|
|
43
68
|
# unicode smiley for testing unicode support!
|
@@ -46,9 +71,11 @@ describe "inputs/pipe", :unix => true do
|
|
46
71
|
end
|
47
72
|
event_count.times.map { queue.pop }
|
48
73
|
end
|
74
|
+
end
|
49
75
|
|
76
|
+
it "should receive all piped elements" do
|
50
77
|
event_count.times do |i|
|
51
|
-
|
78
|
+
expect(events[i]["message"]).to eq("#{i} ☹")
|
52
79
|
end
|
53
80
|
end
|
54
81
|
end
|
metadata
CHANGED
@@ -1,77 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
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-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 2.0.0.snapshot
|
14
19
|
name: logstash-core
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
15
22
|
version_requirements: !ruby/object:Gem::Requirement
|
16
23
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.0
|
20
|
-
- - <
|
24
|
+
- - ~>
|
21
25
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0.0
|
26
|
+
version: 2.0.0.snapshot
|
27
|
+
- !ruby/object:Gem::Dependency
|
23
28
|
requirement: !ruby/object:Gem::Requirement
|
24
29
|
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.4.0
|
28
|
-
- - <
|
30
|
+
- - ~>
|
29
31
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
32
|
+
version: 0.0.22
|
33
|
+
name: stud
|
31
34
|
prerelease: false
|
32
35
|
type: :runtime
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-codec-plain
|
35
36
|
version_requirements: !ruby/object:Gem::Requirement
|
36
37
|
requirements:
|
37
|
-
- -
|
38
|
+
- - ~>
|
38
39
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
+
version: 0.0.22
|
41
|
+
- !ruby/object:Gem::Dependency
|
40
42
|
requirement: !ruby/object:Gem::Requirement
|
41
43
|
requirements:
|
42
44
|
- - '>='
|
43
45
|
- !ruby/object:Gem::Version
|
44
46
|
version: '0'
|
47
|
+
name: logstash-codec-plain
|
45
48
|
prerelease: false
|
46
49
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: logstash-devutils
|
49
50
|
version_requirements: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
52
|
- - '>='
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
54
56
|
requirement: !ruby/object:Gem::Requirement
|
55
57
|
requirements:
|
56
58
|
- - '>='
|
57
59
|
- !ruby/object:Gem::Version
|
58
60
|
version: '0'
|
61
|
+
name: logstash-devutils
|
59
62
|
prerelease: false
|
60
63
|
type: :development
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
61
69
|
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
|
62
70
|
email: info@elastic.co
|
63
71
|
executables: []
|
64
72
|
extensions: []
|
65
73
|
extra_rdoc_files: []
|
66
74
|
files:
|
67
|
-
- .gitignore
|
68
75
|
- CHANGELOG.md
|
69
76
|
- CONTRIBUTORS
|
70
77
|
- Gemfile
|
71
78
|
- LICENSE
|
72
79
|
- NOTICE.TXT
|
73
80
|
- README.md
|
74
|
-
- Rakefile
|
75
81
|
- lib/logstash/inputs/pipe.rb
|
76
82
|
- logstash-input-pipe.gemspec
|
77
83
|
- spec/inputs/pipe_spec.rb
|
@@ -97,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
103
|
version: '0'
|
98
104
|
requirements: []
|
99
105
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.4.8
|
101
107
|
signing_key:
|
102
108
|
specification_version: 4
|
103
109
|
summary: Stream events from a long running command pipe
|
data/.gitignore
DELETED