logstash-input-unix 3.1.1 → 3.1.2
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/inputs/unix.rb +38 -10
- data/logstash-input-unix.gemspec +1 -1
- 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: dce11755b6f6a09ad708f79ee8d9e85fb87e0d98bf2aaedb6d47a316e1de6731
|
4
|
+
data.tar.gz: 84c73daebb51aa1813b528e42113e1a26f73a5162ced25a8c9043648daf54f14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a259754acac7b218a5f62f6341f981266833a26395f3fd4341fcec6ed1af843d891561937cd7a16a2478863d2bd7a5d61b85dfe62a00b4ee3f340b35f3ce02d6
|
7
|
+
data.tar.gz: f85ae87765a0c9ddde40a91d8b4438d4e62d6ec68b1abb187d6c59fa3e643f4ce624656f97a13fd84fde86e85c63021e46f8eafddef1ba05ea8a9557a312b2ca
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 3.1.2
|
2
|
+
- Fix: eliminate high CPU usage when data timeout is disabled and no data is available on the socket [#30](https://github.com/logstash-plugins/logstash-input-unix/pull/30)
|
3
|
+
|
1
4
|
## 3.1.1
|
2
5
|
- Fix: unable to stop plugin (on LS 6.x) [#29](https://github.com/logstash-plugins/logstash-input-unix/pull/29)
|
3
6
|
- Refactor: plugin internals got reviewed for `data_timeout => ...` to work reliably
|
data/lib/logstash/inputs/unix.rb
CHANGED
@@ -84,16 +84,15 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
84
84
|
begin
|
85
85
|
hostname = Socket.gethostname
|
86
86
|
while !stop?
|
87
|
-
data = socket
|
88
|
-
|
89
|
-
if data == :
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
87
|
+
data = io_interruptable_readpartial(socket, 16384, @data_timeout)
|
88
|
+
|
89
|
+
if data == :data_timeout
|
90
|
+
# socket not ready after @data_timeout seconds
|
91
|
+
@logger.info("Closing connection after read timeout", :path => @path)
|
92
|
+
return
|
93
|
+
elsif data == :stopping
|
94
|
+
@logger.trace("Shutdown in progress", :path => @path)
|
95
|
+
next # let next loop handle graceful stop
|
97
96
|
end
|
98
97
|
|
99
98
|
@codec.decode(data) do |event|
|
@@ -118,6 +117,35 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
|
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
120
|
+
##
|
121
|
+
# Emulates `IO#readpartial` with a timeout and our plugin's stop-condition,
|
122
|
+
# limiting blocking calls to windows of 10s or less to ensure it can be interrupted.
|
123
|
+
#
|
124
|
+
# @param readable_io [IO] the IO to read from
|
125
|
+
# @param maxlen [Integer] the max bytes to be read
|
126
|
+
# @param timeout [Number] the maximum number of seconds to , or -1 to disable timeouts
|
127
|
+
#
|
128
|
+
# @return [:data_timeout] if timeout was reached before bytes were available
|
129
|
+
# @return [:stopping] if plugin stop-condition was detected before bytes were available
|
130
|
+
# @return [String] a non-empty string if bytes became available before the timeout was reached
|
131
|
+
def io_interruptable_readpartial(readable_io, maxlen, timeout)
|
132
|
+
|
133
|
+
data_timeout_deadline = timeout < 0 ? nil : Time.now + timeout
|
134
|
+
maximum_blocking_seconds = timeout < 0 || timeout > 10 ? 10 : timeout
|
135
|
+
|
136
|
+
loop do
|
137
|
+
return :stopping if stop?
|
138
|
+
result = readable_io.read_nonblock(maxlen, exception: false)
|
139
|
+
|
140
|
+
return result if result.kind_of?(String)
|
141
|
+
raise EOFError if result.nil?
|
142
|
+
|
143
|
+
return :data_timeout if (data_timeout_deadline && data_timeout_deadline < Time.now)
|
144
|
+
IO.select([readable_io], nil, nil, maximum_blocking_seconds)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
private :io_interruptable_readpartial
|
148
|
+
|
121
149
|
private
|
122
150
|
def server?
|
123
151
|
@mode == "server"
|
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.2'
|
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"
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|