logstash-input-unix 3.1.0 → 3.1.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 +4 -0
- data/lib/logstash/inputs/unix.rb +13 -18
- data/logstash-input-unix.gemspec +1 -1
- data/spec/inputs/unix_spec.rb +23 -2
- data/spec/spec_helper.rb +1 -2
- 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: 211693d1622019fadfcdd5f41b94b7e15594abc983aa54000ea59353392b5d4e
|
4
|
+
data.tar.gz: a8b25c6eb9e1627b502b9177f17510d0e631a72c87883058f3d1f2fa93cb145e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c3c0d4cc5bcdee9fb3a32de4593764f9b458861401569ecd16b6055bb905b4d0bf06da68824d0a8358a77e7f4bce2546736a28c407a6a02535150e85364d375
|
7
|
+
data.tar.gz: da09882dac50d95baef03af89fc1b577ddbd31576d28cbdd02dc42fa350284512050480b231dd59ac6da247d8ec84a71c728ab656a29eb1cf443c0b63a440353
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 3.1.1
|
2
|
+
- Fix: unable to stop plugin (on LS 6.x) [#29](https://github.com/logstash-plugins/logstash-input-unix/pull/29)
|
3
|
+
- Refactor: plugin internals got reviewed for `data_timeout => ...` to work reliably
|
4
|
+
|
1
5
|
## 3.1.0
|
2
6
|
- Feat: adjust fields for ECS compatibility [#28](https://github.com/logstash-plugins/logstash-input-unix/pull/28)
|
3
7
|
|
data/lib/logstash/inputs/unix.rb
CHANGED
@@ -15,8 +15,6 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
15
15
|
|
16
16
|
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8 => :v1)
|
17
17
|
|
18
|
-
class Interrupted < StandardError; end
|
19
|
-
|
20
18
|
config_name "unix"
|
21
19
|
|
22
20
|
default :codec, "line"
|
@@ -54,7 +52,6 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
54
52
|
public
|
55
53
|
def register
|
56
54
|
require "socket"
|
57
|
-
require "timeout"
|
58
55
|
|
59
56
|
if server?
|
60
57
|
@logger.info("Starting unix input listener", :address => @path, :force_unlink => @force_unlink)
|
@@ -87,26 +84,25 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
87
84
|
begin
|
88
85
|
hostname = Socket.gethostname
|
89
86
|
while !stop?
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
87
|
+
data = socket.read_nonblock(16384, exception: false)
|
88
|
+
|
89
|
+
if data == :wait_readable
|
90
|
+
if @data_timeout == -1 || IO.select([socket], nil, nil, @data_timeout)
|
91
|
+
next # retry socket read
|
92
|
+
else
|
93
|
+
# socket not ready after @data_timeout seconds
|
94
|
+
@logger.info("Closing connection after read timeout", :path => @path)
|
95
|
+
return
|
99
96
|
end
|
100
97
|
end
|
101
|
-
|
98
|
+
|
99
|
+
@codec.decode(data) do |event|
|
102
100
|
decorate(event)
|
103
101
|
event.set(@host_name_field, hostname) unless event.include?(@host_name_field)
|
104
102
|
event.set(@file_path_field, @path) unless event.include?(@file_path_field)
|
105
103
|
output_queue << event
|
106
104
|
end
|
107
105
|
end
|
108
|
-
rescue Timeout::Error
|
109
|
-
@logger.info("Closing connection after read timeout", :path => @path)
|
110
106
|
rescue => e
|
111
107
|
if @logger.debug?
|
112
108
|
@logger.debug("Closing connection", :path => @path, :exception => e, :backtrace => e.backtrace)
|
@@ -114,7 +110,6 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
114
110
|
@logger.info("Closing connection", :path => @path, :exception => e)
|
115
111
|
end
|
116
112
|
end
|
117
|
-
|
118
113
|
ensure
|
119
114
|
begin
|
120
115
|
socket.close
|
@@ -141,9 +136,9 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
141
136
|
end
|
142
137
|
else
|
143
138
|
while !stop?
|
144
|
-
if File.socket?(@path)
|
139
|
+
if File.socket?(@path)
|
145
140
|
@client_socket = UNIXSocket.new(@path)
|
146
|
-
@client_socket.
|
141
|
+
@client_socket.extend ::LogStash::Util::SocketPeer
|
147
142
|
@logger.debug("Opened connection", :client => @path)
|
148
143
|
handle_socket(@client_socket, output_queue)
|
149
144
|
else
|
data/logstash-input-unix.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-unix'
|
4
|
-
s.version = '3.1.
|
4
|
+
s.version = '3.1.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Reads events over a UNIX socket"
|
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/unix_spec.rb
CHANGED
@@ -55,8 +55,29 @@ describe LogStash::Inputs::Unix do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
context "when the unix socket has no data to be read" do
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
let(:run_forever) { false }
|
60
|
+
|
61
|
+
it_behaves_like "an interruptible input plugin"
|
62
|
+
|
63
|
+
context 'with timeout' do
|
64
|
+
|
65
|
+
let(:config) { super().merge "data_timeout" => 1.0 }
|
66
|
+
|
67
|
+
let(:queue) { SizedQueue.new(10) }
|
68
|
+
before(:each) { subject.register }
|
69
|
+
after(:each) { subject.do_stop }
|
70
|
+
|
71
|
+
it "closes socket after timeout" do
|
72
|
+
plugin_thread = Thread.new(subject, queue) { |subject, queue| subject.run(queue) }
|
73
|
+
sleep 0.5
|
74
|
+
client_socket = subject.instance_variable_get :@client_socket
|
75
|
+
expect( client_socket.closed? ).to be false
|
76
|
+
sleep 1.0 # allow timeout to kick in
|
77
|
+
expect( client_socket.closed? ).to be true
|
78
|
+
expect( plugin_thread ).to be_alive
|
79
|
+
end
|
80
|
+
|
60
81
|
end
|
61
82
|
end
|
62
83
|
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ class UnixSocketHelper
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def new_socket(path)
|
15
|
-
@path
|
15
|
+
@path = path
|
16
16
|
File.unlink if File.exists?(path) && File.socket?(path)
|
17
17
|
@socket = UNIXServer.new(path)
|
18
18
|
self
|
@@ -31,7 +31,6 @@ class UnixSocketHelper
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def close
|
34
|
-
@thread.kill
|
35
34
|
@socket.close
|
36
35
|
File.unlink(path)
|
37
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-unix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|