fluentd 0.10.62 → 0.12.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.travis.yml +0 -4
- data/ChangeLog +0 -72
- data/Gemfile +0 -6
- data/Rakefile +12 -3
- data/example/in_http.conf +14 -0
- data/example/in_syslog.conf +15 -0
- data/example/in_tail.conf +14 -0
- data/example/in_tcp.conf +13 -0
- data/example/in_udp.conf +13 -0
- data/example/out_copy.conf +20 -0
- data/example/out_file.conf +13 -0
- data/example/out_forward.conf +30 -0
- data/fluent.conf +2 -12
- data/fluentd.gemspec +8 -11
- data/lib/fluent/agent.rb +180 -0
- data/lib/fluent/buffer.rb +6 -12
- data/lib/fluent/command/cat.rb +1 -3
- data/lib/fluent/command/debug.rb +1 -3
- data/lib/fluent/command/fluentd.rb +0 -10
- data/lib/fluent/config.rb +9 -3
- data/lib/fluent/config/basic_parser.rb +1 -6
- data/lib/fluent/config/configure_proxy.rb +25 -61
- data/lib/fluent/config/dsl.rb +16 -0
- data/lib/fluent/config/element.rb +21 -2
- data/lib/fluent/config/error.rb +16 -0
- data/lib/fluent/config/literal_parser.rb +9 -27
- data/lib/fluent/config/parser.rb +16 -0
- data/lib/fluent/config/section.rb +16 -2
- data/lib/fluent/config/types.rb +16 -1
- data/lib/fluent/config/v1_parser.rb +4 -12
- data/lib/fluent/configurable.rb +16 -0
- data/lib/fluent/engine.rb +43 -163
- data/lib/fluent/env.rb +16 -1
- data/lib/fluent/event.rb +20 -48
- data/lib/fluent/event_router.rb +187 -0
- data/lib/fluent/filter.rb +32 -0
- data/lib/fluent/formatter.rb +29 -101
- data/lib/fluent/input.rb +6 -4
- data/lib/fluent/label.rb +18 -0
- data/lib/fluent/load.rb +1 -3
- data/lib/fluent/log.rb +1 -3
- data/lib/fluent/match.rb +12 -19
- data/lib/fluent/mixin.rb +9 -25
- data/lib/fluent/output.rb +27 -45
- data/lib/fluent/parser.rb +93 -99
- data/lib/fluent/plugin.rb +22 -48
- data/lib/fluent/plugin/buf_file.rb +10 -7
- data/lib/fluent/plugin/buf_memory.rb +2 -3
- data/lib/fluent/plugin/buf_zfile.rb +75 -0
- data/lib/fluent/plugin/exec_util.rb +16 -0
- data/lib/fluent/plugin/in_debug_agent.rb +2 -3
- data/lib/fluent/plugin/in_exec.rb +2 -9
- data/lib/fluent/plugin/in_forward.rb +4 -22
- data/lib/fluent/plugin/in_gc_stat.rb +2 -3
- data/lib/fluent/plugin/in_http.rb +19 -59
- data/lib/fluent/plugin/in_monitor_agent.rb +21 -47
- data/lib/fluent/plugin/in_object_space.rb +2 -3
- data/lib/fluent/plugin/in_status.rb +2 -3
- data/lib/fluent/plugin/in_stream.rb +6 -16
- data/lib/fluent/plugin/in_syslog.rb +8 -17
- data/lib/fluent/plugin/in_tail.rb +17 -24
- data/lib/fluent/plugin/in_tcp.rb +16 -0
- data/lib/fluent/plugin/in_udp.rb +16 -0
- data/lib/fluent/plugin/out_copy.rb +3 -4
- data/lib/fluent/plugin/out_exec.rb +2 -4
- data/lib/fluent/plugin/out_exec_filter.rb +2 -13
- data/lib/fluent/plugin/out_file.rb +5 -6
- data/lib/fluent/plugin/out_forward.rb +4 -5
- data/lib/fluent/plugin/out_null.rb +2 -3
- data/lib/fluent/plugin/out_relabel.rb +26 -0
- data/lib/fluent/plugin/out_roundrobin.rb +3 -4
- data/lib/fluent/plugin/out_stdout.rb +2 -3
- data/lib/fluent/plugin/out_stream.rb +2 -3
- data/{test/scripts → lib}/fluent/plugin/out_test.rb +2 -3
- data/lib/fluent/plugin/socket_util.rb +19 -10
- data/lib/fluent/process.rb +4 -6
- data/lib/fluent/registry.rb +16 -0
- data/lib/fluent/root_agent.rb +212 -0
- data/lib/fluent/status.rb +2 -3
- data/lib/fluent/supervisor.rb +33 -54
- data/lib/fluent/test.rb +16 -0
- data/lib/fluent/test/base.rb +3 -17
- data/lib/fluent/test/input_test.rb +52 -7
- data/lib/fluent/test/output_test.rb +4 -20
- data/lib/fluent/version.rb +17 -1
- data/spec/config/config_parser_spec.rb +314 -0
- data/spec/config/configurable_spec.rb +524 -0
- data/spec/config/configure_proxy_spec.rb +96 -0
- data/spec/config/dsl_spec.rb +239 -0
- data/spec/config/helper.rb +49 -0
- data/spec/config/literal_parser_spec.rb +222 -0
- data/spec/config/section_spec.rb +97 -0
- data/spec/config/system_config_spec.rb +49 -0
- data/test/helper.rb +0 -25
- data/test/plugin/test_in_exec.rb +1 -1
- data/test/plugin/test_in_forward.rb +2 -1
- data/test/plugin/test_in_gc_stat.rb +1 -1
- data/test/plugin/test_in_http.rb +3 -78
- data/test/plugin/test_in_object_space.rb +1 -1
- data/test/plugin/test_in_status.rb +1 -1
- data/test/plugin/test_in_stream.rb +2 -1
- data/test/plugin/test_in_syslog.rb +2 -1
- data/test/plugin/test_in_tail.rb +6 -11
- data/test/plugin/test_in_tcp.rb +2 -1
- data/test/plugin/test_in_udp.rb +2 -1
- data/test/plugin/test_out_copy.rb +1 -12
- data/test/plugin/test_out_exec.rb +1 -1
- data/test/plugin/test_out_exec_filter.rb +1 -1
- data/test/plugin/test_out_file.rb +7 -96
- data/test/plugin/test_out_forward.rb +2 -1
- data/test/plugin/test_out_roundrobin.rb +1 -12
- data/test/plugin/test_out_stdout.rb +1 -1
- data/test/plugin/test_out_stream.rb +2 -1
- data/test/scripts/fluent/plugin/formatter_known.rb +1 -4
- data/test/scripts/fluent/plugin/parser_known.rb +1 -2
- data/test/test_config.rb +1 -1
- data/test/test_configdsl.rb +2 -1
- data/test/test_formatter.rb +3 -395
- data/test/test_match.rb +2 -1
- data/test/test_mixin.rb +3 -75
- data/test/test_output.rb +1 -112
- data/test/test_parser.rb +85 -152
- metadata +58 -167
- data/example/v1_literal_example.conf +0 -36
- data/lib/fluent/plugin/in_dummy.rb +0 -103
- data/lib/fluent/timezone.rb +0 -131
- data/test/config/assertions.rb +0 -42
- data/test/config/test_config_parser.rb +0 -389
- data/test/config/test_configurable.rb +0 -652
- data/test/config/test_configure_proxy.rb +0 -99
- data/test/config/test_dsl.rb +0 -237
- data/test/config/test_literal_parser.rb +0 -295
- data/test/config/test_section.rb +0 -112
- data/test/config/test_system_config.rb +0 -99
- data/test/config/test_types.rb +0 -63
- data/test/plugin/test_in_dummy.rb +0 -95
- data/test/test_event.rb +0 -168
- data/test/test_input.rb +0 -21
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 FURUHASHI Sadayuki
|
2
|
+
# Fluentd
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +13,7 @@
|
|
15
13
|
# See the License for the specific language governing permissions and
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
16
|
+
|
18
17
|
module Fluent
|
19
18
|
class MonitorAgentInput < Input
|
20
19
|
Plugin.register_input('monitor_agent', self)
|
@@ -77,7 +76,7 @@ module Fluent
|
|
77
76
|
opts[:pretty_json] = true
|
78
77
|
end
|
79
78
|
|
80
|
-
if
|
79
|
+
if tags = qs['tag'] and tag = tags[0]
|
81
80
|
# ?tag= to search an output plugin by match pattern
|
82
81
|
if obj = @agent.plugin_info_by_tag(tag, opts)
|
83
82
|
list = [obj]
|
@@ -85,29 +84,17 @@ module Fluent
|
|
85
84
|
list = []
|
86
85
|
end
|
87
86
|
|
88
|
-
elsif
|
89
|
-
#
|
87
|
+
elsif plugin_ids = qs['id'] and plugin_id = plugin_ids[0]
|
88
|
+
# ?id= to search a plugin by 'id <plugin_id>' config param
|
90
89
|
if obj = @agent.plugin_info_by_id(plugin_id, opts)
|
91
90
|
list = [obj]
|
92
91
|
else
|
93
92
|
list = []
|
94
93
|
end
|
95
94
|
|
96
|
-
elsif
|
97
|
-
#
|
98
|
-
|
99
|
-
list = [obj]
|
100
|
-
else
|
101
|
-
list = []
|
102
|
-
end
|
103
|
-
|
104
|
-
elsif plugin_type = get_search_parameter(qs, '@type'.freeze)
|
105
|
-
# ?@type= to search plugins by 'type <type>' config param
|
106
|
-
list = @agent.plugins_info_by_type(plugin_type, opts)
|
107
|
-
|
108
|
-
elsif plugin_type = get_search_parameter(qs, 'type'.freeze)
|
109
|
-
# Without @ version of ?@type= for backward compatibility
|
110
|
-
list = @agent.plugins_info_by_type(plugin_type, opts)
|
95
|
+
elsif types = qs['type'] and type = types[0]
|
96
|
+
# ?type= to search plugins by 'type <type>' config param
|
97
|
+
list = @agent.plugins_info_by_type(type, opts)
|
111
98
|
|
112
99
|
else
|
113
100
|
# otherwise show all plugins
|
@@ -117,11 +104,6 @@ module Fluent
|
|
117
104
|
return list, opts
|
118
105
|
end
|
119
106
|
|
120
|
-
def get_search_parameter(qs, param_name)
|
121
|
-
return nil unless qs.has_key?(param_name)
|
122
|
-
qs[param_name].first
|
123
|
-
end
|
124
|
-
|
125
107
|
def render_json(obj, opts={})
|
126
108
|
render_json_error(200, obj, opts)
|
127
109
|
end
|
@@ -229,21 +211,30 @@ module Fluent
|
|
229
211
|
end
|
230
212
|
|
231
213
|
MONITOR_INFO = {
|
214
|
+
'plugin_id' => 'plugin_id',
|
215
|
+
'type' => 'config["type"]',
|
232
216
|
'output_plugin' => 'is_a?(::Fluent::Output)',
|
233
217
|
'buffer_queue_length' => '@buffer.queue_size',
|
234
218
|
'buffer_total_queued_size' => '@buffer.total_queued_chunk_size',
|
235
219
|
'retry_count' => '@num_errors',
|
220
|
+
'config' => 'config',
|
236
221
|
}
|
237
222
|
|
238
223
|
def all_plugins
|
239
224
|
array = []
|
240
225
|
|
241
226
|
# get all input plugins
|
242
|
-
array.concat Engine.
|
227
|
+
array.concat Engine.root_agent.inputs
|
243
228
|
|
244
229
|
# get all output plugins
|
245
|
-
Engine.
|
246
|
-
MonitorAgentInput.collect_children(
|
230
|
+
Engine.root_agent.outputs.each { |o|
|
231
|
+
MonitorAgentInput.collect_children(o, array)
|
232
|
+
}
|
233
|
+
Engine.root_agent.labels.each { |name, l|
|
234
|
+
# TODO: Add label name to outputs for identifing plugins
|
235
|
+
l.outputs.each { |o|
|
236
|
+
MonitorAgentInput.collect_children(o, array)
|
237
|
+
}
|
247
238
|
}
|
248
239
|
|
249
240
|
array
|
@@ -289,7 +280,7 @@ module Fluent
|
|
289
280
|
# multiple plugins could have the same type
|
290
281
|
def plugins_info_by_type(type, opts={})
|
291
282
|
array = all_plugins.select {|pe|
|
292
|
-
|
283
|
+
pe.config['type'] == type rescue nil
|
293
284
|
}
|
294
285
|
array.map {|pe|
|
295
286
|
get_monitor_info(pe, opts)
|
@@ -306,12 +297,6 @@ module Fluent
|
|
306
297
|
def get_monitor_info(pe, opts={})
|
307
298
|
obj = {}
|
308
299
|
|
309
|
-
# Common plugin information
|
310
|
-
obj['plugin_id'] = pe.plugin_id
|
311
|
-
obj['plugin_category'] = plugin_category(pe)
|
312
|
-
obj['type'] = pe.config['@type'] || pe.config['type']
|
313
|
-
obj['config'] = pe.config
|
314
|
-
|
315
300
|
# run MONITOR_INFO in plugins' instance context and store the info to obj
|
316
301
|
MONITOR_INFO.each_pair {|key,code|
|
317
302
|
begin
|
@@ -335,17 +320,6 @@ module Fluent
|
|
335
320
|
obj
|
336
321
|
end
|
337
322
|
|
338
|
-
def plugin_category(pe)
|
339
|
-
case pe
|
340
|
-
when Fluent::Input
|
341
|
-
'input'.freeze
|
342
|
-
when Fluent::Output
|
343
|
-
'output'.freeze
|
344
|
-
else
|
345
|
-
'unknown'.freeze
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
323
|
def fluentd_opts
|
350
324
|
@fluentd_opts ||= get_fluentd_opts
|
351
325
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 FURUHASHI Sadayuki
|
2
|
+
# Fluentd
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +13,7 @@
|
|
15
13
|
# See the License for the specific language governing permissions and
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
16
|
+
|
18
17
|
module Fluent
|
19
18
|
class ObjectSpaceInput < Input
|
20
19
|
Plugin.register_input('object_space', self)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 FURUHASHI Sadayuki
|
2
|
+
# Fluentd
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +13,7 @@
|
|
15
13
|
# See the License for the specific language governing permissions and
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
16
|
+
|
18
17
|
module Fluent
|
19
18
|
class StatusInput < Input
|
20
19
|
Plugin.register_input('status', self)
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 FURUHASHI Sadayuki
|
2
|
+
# Fluentd
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,9 +13,12 @@
|
|
15
13
|
# See the License for the specific language governing permissions and
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
16
|
+
|
18
17
|
module Fluent
|
19
18
|
# obsolete
|
20
19
|
class StreamInput < Input
|
20
|
+
config_param :blocking_timeout, :time, :default => 0.5
|
21
|
+
|
21
22
|
def initialize
|
22
23
|
require 'socket'
|
23
24
|
require 'yajl'
|
@@ -29,7 +30,6 @@ module Fluent
|
|
29
30
|
@lsock = listen
|
30
31
|
@loop.attach(@lsock)
|
31
32
|
@thread = Thread.new(&method(:run))
|
32
|
-
@cached_unpacker = $use_msgpack_5 ? nil : MessagePack::Unpacker.new
|
33
33
|
end
|
34
34
|
|
35
35
|
def shutdown
|
@@ -43,22 +43,13 @@ module Fluent
|
|
43
43
|
#end
|
44
44
|
|
45
45
|
def run
|
46
|
-
|
47
|
-
@loop.run(0.5)
|
48
|
-
else
|
49
|
-
@loop.run
|
50
|
-
end
|
46
|
+
@loop.run(@blocking_timeout)
|
51
47
|
rescue
|
52
48
|
log.error "unexpected error", :error=>$!.to_s
|
53
49
|
log.error_backtrace
|
54
50
|
end
|
55
51
|
|
56
52
|
protected
|
57
|
-
|
58
|
-
def support_blocking_timeout?
|
59
|
-
@loop.method(:run).arity.nonzero?
|
60
|
-
end
|
61
|
-
|
62
53
|
# message Entry {
|
63
54
|
# 1: long time
|
64
55
|
# 2: object record
|
@@ -86,7 +77,7 @@ module Fluent
|
|
86
77
|
|
87
78
|
if entries.class == String
|
88
79
|
# PackedForward
|
89
|
-
es = MessagePackEventStream.new(entries
|
80
|
+
es = MessagePackEventStream.new(entries)
|
90
81
|
router.emit_stream(tag, es)
|
91
82
|
|
92
83
|
elsif entries.class == Array
|
@@ -192,4 +183,3 @@ module Fluent
|
|
192
183
|
end
|
193
184
|
end
|
194
185
|
end
|
195
|
-
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 FURUHASHI Sadayuki
|
2
|
+
# Fluentd
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +13,7 @@
|
|
15
13
|
# See the License for the specific language governing permissions and
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
16
|
+
|
18
17
|
module Fluent
|
19
18
|
class SyslogInput < Input
|
20
19
|
Plugin.register_input('syslog', self)
|
@@ -80,13 +79,14 @@ module Fluent
|
|
80
79
|
end
|
81
80
|
config_param :include_source_host, :bool, :default => false
|
82
81
|
config_param :source_host_key, :string, :default => 'source_host'.freeze
|
82
|
+
config_param :blocking_timeout, :time, :default => 0.5
|
83
83
|
|
84
84
|
def configure(conf)
|
85
85
|
super
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
@parser
|
87
|
+
parser = TextParser.new
|
88
|
+
if parser.configure(conf, false)
|
89
|
+
@parser = parser
|
90
90
|
else
|
91
91
|
conf['with_priority'] = true
|
92
92
|
@parser = TextParser::SyslogParser.new
|
@@ -117,22 +117,13 @@ module Fluent
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def run
|
120
|
-
|
121
|
-
@loop.run(0.5)
|
122
|
-
else
|
123
|
-
@loop.run
|
124
|
-
end
|
120
|
+
@loop.run(@blocking_timeout)
|
125
121
|
rescue
|
126
122
|
log.error "unexpected error", :error=>$!.to_s
|
127
123
|
log.error_backtrace
|
128
124
|
end
|
129
125
|
|
130
126
|
protected
|
131
|
-
|
132
|
-
def support_blocking_timeout?
|
133
|
-
@loop.method(:run).arity.nonzero?
|
134
|
-
end
|
135
|
-
|
136
127
|
def receive_data_parser(data, addr)
|
137
128
|
m = SYSLOG_REGEXP.match(data)
|
138
129
|
unless m
|
@@ -157,7 +148,7 @@ module Fluent
|
|
157
148
|
end
|
158
149
|
|
159
150
|
def receive_data(data, addr)
|
160
|
-
@parser.
|
151
|
+
@parser.call(data) { |time, record|
|
161
152
|
unless time && record
|
162
153
|
log.warn "invalid syslog message", :data => data
|
163
154
|
return
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# Copyright (C) 2011 FURUHASHI Sadayuki
|
2
|
+
# Fluentd
|
5
3
|
#
|
6
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
5
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +13,7 @@
|
|
15
13
|
# See the License for the specific language governing permissions and
|
16
14
|
# limitations under the License.
|
17
15
|
#
|
16
|
+
|
18
17
|
module Fluent
|
19
18
|
class NewTailInput < Input
|
20
19
|
Plugin.register_input('tail', self)
|
@@ -27,7 +26,6 @@ module Fluent
|
|
27
26
|
|
28
27
|
config_param :path, :string
|
29
28
|
config_param :tag, :string
|
30
|
-
config_param :exclude_path, :array, :default => []
|
31
29
|
config_param :rotate_wait, :time, :default => 5
|
32
30
|
config_param :pos_file, :string, :default => nil
|
33
31
|
config_param :read_from_head, :bool, :default => false
|
@@ -51,7 +49,7 @@ module Fluent
|
|
51
49
|
configure_parser(conf)
|
52
50
|
configure_tag
|
53
51
|
|
54
|
-
@multiline_mode = conf['format']
|
52
|
+
@multiline_mode = conf['format'] == 'multiline'
|
55
53
|
@receive_handler = if @multiline_mode
|
56
54
|
method(:parse_multilines)
|
57
55
|
else
|
@@ -60,7 +58,7 @@ module Fluent
|
|
60
58
|
end
|
61
59
|
|
62
60
|
def configure_parser(conf)
|
63
|
-
@parser =
|
61
|
+
@parser = TextParser.new
|
64
62
|
@parser.configure(conf)
|
65
63
|
end
|
66
64
|
|
@@ -101,8 +99,6 @@ module Fluent
|
|
101
99
|
def expand_paths
|
102
100
|
date = Time.now
|
103
101
|
paths = []
|
104
|
-
|
105
|
-
excluded = @exclude_path.map { |path| path = date.strftime(path); path.include?('*') ? Dir.glob(path) : path }.flatten.uniq
|
106
102
|
@paths.each { |path|
|
107
103
|
path = date.strftime(path)
|
108
104
|
if path.include?('*')
|
@@ -112,7 +108,7 @@ module Fluent
|
|
112
108
|
paths << path
|
113
109
|
end
|
114
110
|
}
|
115
|
-
paths
|
111
|
+
paths
|
116
112
|
end
|
117
113
|
|
118
114
|
# in_tail with '*' path doesn't check rotation file equality at refresh phase.
|
@@ -261,9 +257,9 @@ module Fluent
|
|
261
257
|
def parse_multilines(lines, tail_watcher)
|
262
258
|
lb = tail_watcher.line_buffer
|
263
259
|
es = MultiEventStream.new
|
264
|
-
if @parser.has_firstline?
|
260
|
+
if @parser.parser.has_firstline?
|
265
261
|
lines.each { |line|
|
266
|
-
if @parser.firstline?(line)
|
262
|
+
if @parser.parser.firstline?(line)
|
267
263
|
if lb
|
268
264
|
convert_line_to_event(lb, es)
|
269
265
|
end
|
@@ -601,7 +597,7 @@ module Fluent
|
|
601
597
|
@file.write path
|
602
598
|
@file.write "\t"
|
603
599
|
seek = @file.pos
|
604
|
-
@file.write "0000000000000000\
|
600
|
+
@file.write "0000000000000000\t00000000\n"
|
605
601
|
@last_pos = @file.pos
|
606
602
|
|
607
603
|
@map[path] = FilePositionEntry.new(@file, seek)
|
@@ -627,15 +623,12 @@ module Fluent
|
|
627
623
|
# Clean up unwatched file entries
|
628
624
|
def self.compact(file)
|
629
625
|
file.pos = 0
|
630
|
-
existent_entries = file.each_line.
|
626
|
+
existent_entries = file.each_line.select { |line|
|
631
627
|
m = /^([^\t]+)\t([0-9a-fA-F]+)\t([0-9a-fA-F]+)/.match(line)
|
632
628
|
next unless m
|
633
|
-
path = m[1]
|
634
629
|
pos = m[2].to_i(16)
|
635
|
-
|
636
|
-
|
637
|
-
pos == UNWATCHED_POSITION ? nil : ("%s\t%016x\t%016x\n" % [path, pos, ino])
|
638
|
-
}.compact
|
630
|
+
pos == UNWATCHED_POSITION ? nil : line
|
631
|
+
}
|
639
632
|
|
640
633
|
file.pos = 0
|
641
634
|
file.truncate(0)
|
@@ -644,13 +637,13 @@ module Fluent
|
|
644
637
|
end
|
645
638
|
|
646
639
|
# pos inode
|
647
|
-
# ffffffffffffffff\
|
640
|
+
# ffffffffffffffff\tffffffff\n
|
648
641
|
class FilePositionEntry
|
649
642
|
POS_SIZE = 16
|
650
643
|
INO_OFFSET = 17
|
651
|
-
INO_SIZE =
|
652
|
-
LN_OFFSET =
|
653
|
-
SIZE =
|
644
|
+
INO_SIZE = 8
|
645
|
+
LN_OFFSET = 25
|
646
|
+
SIZE = 26
|
654
647
|
|
655
648
|
def initialize(file, seek)
|
656
649
|
@file = file
|
@@ -659,7 +652,7 @@ module Fluent
|
|
659
652
|
|
660
653
|
def update(ino, pos)
|
661
654
|
@file.pos = @seek
|
662
|
-
@file.write "%016x\t%
|
655
|
+
@file.write "%016x\t%08x" % [pos, ino]
|
663
656
|
end
|
664
657
|
|
665
658
|
def update_pos(pos)
|
@@ -669,7 +662,7 @@ module Fluent
|
|
669
662
|
|
670
663
|
def read_inode
|
671
664
|
@file.pos = @seek + INO_OFFSET
|
672
|
-
raw = @file.read(
|
665
|
+
raw = @file.read(8)
|
673
666
|
raw ? raw.to_i(16) : 0
|
674
667
|
end
|
675
668
|
|
data/lib/fluent/plugin/in_tcp.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
1
17
|
require 'fluent/plugin/socket_util'
|
2
18
|
|
3
19
|
module Fluent
|