logstash-input-unix 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802f228d5171d486df4c13144d64328c687c8f33
4
- data.tar.gz: b9b690ed2ec59d91082ced3cce0e6aaac8d612ba
3
+ metadata.gz: ce52177d18d3c4f2ac356640d08c48919f451689
4
+ data.tar.gz: b803f47cb17a6d147805ed0ab8070cd8a7ffc61a
5
5
  SHA512:
6
- metadata.gz: ad2385a3d79601cb05ad859db2ece700c57c4f6e76385de8740851ee3aa1ac3b214ba0561f0b2aca393dd25871afe91f4b8c7aa2af17699c44c9ad4d285f105d
7
- data.tar.gz: 89eecc30de4a94594f9b94d82b6cf9b91bf571079b50f76b17f3006823223d4a5ee93fe309cd48b4f5ade95603ea7034ca345f794c5ac9fc9b859a16b96a711f
6
+ metadata.gz: f6565a89ff69dae14c7459852a8af7302667f24d94f0e1e5192aa62a94efb760357d68741358ab28093855994293ac6d820adf1f9ba4767a84e7b6b7dfe08b5d
7
+ data.tar.gz: bacb3762def1d9a9f2890e4006fc48893f99f44edd1e3b6a66f5a4e43b1acecb81d8aca2e6bf118c02d0c61df3f290bff73343c58fb4a6bb7e85fb126c5bbaa9
@@ -1,3 +1,6 @@
1
+ ## 3.0.3
2
+ - Preserve values provided in `add_field` for `host` and `path`.
3
+
1
4
  ## 3.0.2
2
5
  - Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
3
6
 
@@ -32,6 +32,12 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
32
32
  # `client` connects to a server.
33
33
  config :mode, :validate => ["server", "client"], :default => "server"
34
34
 
35
+ # Amount of time in seconds to wait if the socket file is not present, before retrying.
36
+ # Only positive values are allowed.
37
+ #
38
+ # This setting is only used if `mode` is `client`.
39
+ config :socket_not_present_retry_interval_seconds, :validate => :number, :required => true, :default => 5
40
+
35
41
  def initialize(*args)
36
42
  super(*args)
37
43
  end # def initialize
@@ -61,6 +67,11 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
61
67
  :path => @path)
62
68
  raise
63
69
  end
70
+ else # client
71
+ if @socket_not_present_retry_interval_seconds < 0
72
+ @logger.warn("Value #{@socket_not_present_retry_interval_seconds} for socket_not_present_retry_interval_seconds is not valid, using default value of 5 instead")
73
+ @socket_not_present_retry_interval_seconds = 5
74
+ end
64
75
  end
65
76
  end # def register
66
77
 
@@ -82,8 +93,8 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
82
93
  end
83
94
  @codec.decode(buf) do |event|
84
95
  decorate(event)
85
- event.set("host", hostname)
86
- event.set("path", @path)
96
+ event.set("host", hostname) unless event.include?("host")
97
+ event.set("path", @path) unless event.include?("path")
87
98
  output_queue << event
88
99
  end
89
100
  end
@@ -119,10 +130,15 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
119
130
  end
120
131
  else
121
132
  while !stop?
122
- @client_socket = UNIXSocket.new(@path)
123
- @client_socket.instance_eval { class << self; include ::LogStash::Util::SocketPeer end }
124
- @logger.debug("Opened connection", :client => @path)
125
- handle_socket(@client_socket, output_queue)
133
+ if File.socket?(@path) then
134
+ @client_socket = UNIXSocket.new(@path)
135
+ @client_socket.instance_eval { class << self; include ::LogStash::Util::SocketPeer end }
136
+ @logger.debug("Opened connection", :client => @path)
137
+ handle_socket(@client_socket, output_queue)
138
+ else
139
+ @logger.warn("Socket not present, wait for #{@subscription_retry_interval_seconds} seconds for socket to appear", :client => @path)
140
+ sleep @socket_not_present_retry_interval_seconds
141
+ end
126
142
  end
127
143
  end
128
144
  rescue IOError
@@ -135,9 +151,13 @@ class LogStash::Inputs::Unix < LogStash::Inputs::Base
135
151
  def stop
136
152
  if server?
137
153
  File.unlink(@path)
138
- @server_socket.close
154
+ @server_socket.close unless @server_socket.nil?
139
155
  else
140
- @client_socket.close
156
+ @client_socket.close unless @client_socket.nil?
141
157
  end
158
+ rescue IOError
159
+ # if socket with @mode == client was closed by the client, an other call to @client_socket.close
160
+ # will raise an IOError. We catch IOError here and do nothing, just let logstash terminate
161
+ @logger.warn("Cloud not close socket while Logstash is shutting down. Socket already closed by the other party?", :path => @path)
142
162
  end # def stop
143
163
  end # class LogStash::Inputs::Unix
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-unix'
4
- s.version = '3.0.2'
4
+ s.version = '3.0.3'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Read 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"
@@ -12,6 +12,19 @@ describe LogStash::Inputs::Unix do
12
12
  expect { plugin.register }.to_not raise_error
13
13
  end
14
14
 
15
+ describe "when mode is client" do
16
+
17
+ let(:mode) { "client" }
18
+
19
+ context "if socket_not_present_retry_interval_seconds is out of bounds" do
20
+ it "should fallback to default value" do
21
+ plugin = LogStash::Plugin.lookup("input", "unix").new({ "path" => tempfile.path, "force_unlink" => true, "mode" => mode, "socket_not_present_retry_interval_seconds" => -1 })
22
+ plugin.register
23
+ expect(plugin.instance_variable_get(:@socket_not_present_retry_interval_seconds)).to be 5
24
+ end
25
+ end
26
+ end
27
+
15
28
  describe "when interrupting the plugin" do
16
29
 
17
30
  context "#server" do
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.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  version: '0'
97
97
  requirements: []
98
98
  rubyforge_project:
99
- rubygems_version: 2.6.3
99
+ rubygems_version: 2.4.8
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Read events over a UNIX socket.