fluent-plugin-systemd 0.0.5 → 0.0.6
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/Gemfile +1 -0
- data/Gemfile.lock +22 -24
- data/README.md +19 -7
- data/fluent-plugin-systemd.gemspec +3 -3
- data/lib/fluent/plugin/in_systemd.rb +25 -20
- data/lib/fluent/plugin/systemd/pos_writer.rb +16 -16
- data/pkg/fluent-plugin-systemd-0.0.5.gem +0 -0
- data/pkg/fluent-plugin-systemd-0.1.0.gem +0 -0
- metadata +9 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b743a85ec91f64910f7c323a6ac9c3ba2f3dc8be
|
|
4
|
+
data.tar.gz: df1ca5c2c12b2d46e7d97fc03dc7c8c6fedf388e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c9e624bc2f7ee2d996b28180d7fd9dbf46748b9f3d45dc65b6ad90bbedf57da2b44a72e25db87782f1f02dd00f8f1af14eb1b5a30205cf953ec0e0e8a8ea8e0
|
|
7
|
+
data.tar.gz: 624889ccba1c2176c71fd763699cc57470136820f4afa2a8241a61a7fe7586cfebe3d499bf7a65dd531fbfa0d1680b3041802a56c5e501f64087f39ba95a4eae
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fluent-plugin-systemd (0.0.
|
|
4
|
+
fluent-plugin-systemd (0.0.6)
|
|
5
5
|
fluentd (~> 0.12)
|
|
6
6
|
systemd-journal (~> 1.2)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
ast (2.
|
|
11
|
+
ast (2.3.0)
|
|
12
12
|
astrolabe (1.3.1)
|
|
13
13
|
parser (~> 2.2)
|
|
14
|
-
cool.io (1.4.
|
|
15
|
-
ffi (1.9.
|
|
16
|
-
fluentd (0.
|
|
17
|
-
cool.io (>= 1.
|
|
14
|
+
cool.io (1.4.5)
|
|
15
|
+
ffi (1.9.17)
|
|
16
|
+
fluentd (0.12.31)
|
|
17
|
+
cool.io (>= 1.2.2, < 2.0.0)
|
|
18
18
|
http_parser.rb (>= 0.5.1, < 0.7.0)
|
|
19
19
|
json (>= 1.4.3)
|
|
20
|
-
msgpack (>= 0.
|
|
21
|
-
serverengine (>= 1.6.4)
|
|
20
|
+
msgpack (>= 0.5.11, < 0.6.0)
|
|
22
21
|
sigdump (~> 0.2.2)
|
|
23
|
-
|
|
22
|
+
string-scrub (>= 0.0.3, <= 0.0.5)
|
|
24
23
|
tzinfo (>= 1.0.0)
|
|
25
24
|
tzinfo-data (>= 1.0.0)
|
|
26
25
|
yajl-ruby (~> 1.0)
|
|
27
26
|
http_parser.rb (0.6.0)
|
|
28
|
-
json (2.0.
|
|
29
|
-
msgpack (
|
|
30
|
-
parser (2.3.1
|
|
27
|
+
json (2.0.3)
|
|
28
|
+
msgpack (0.5.12)
|
|
29
|
+
parser (2.3.3.1)
|
|
31
30
|
ast (~> 2.2)
|
|
32
31
|
powerpack (0.0.9)
|
|
33
|
-
rainbow (2.1
|
|
34
|
-
rake (
|
|
35
|
-
reevoocop (0.0.
|
|
32
|
+
rainbow (2.2.1)
|
|
33
|
+
rake (12.0.0)
|
|
34
|
+
reevoocop (0.0.9)
|
|
36
35
|
rubocop (= 0.28.0)
|
|
37
36
|
rubocop (0.28.0)
|
|
38
37
|
astrolabe (~> 1.3)
|
|
@@ -40,20 +39,18 @@ GEM
|
|
|
40
39
|
powerpack (~> 0.0.6)
|
|
41
40
|
rainbow (>= 1.99.1, < 3.0)
|
|
42
41
|
ruby-progressbar (~> 1.4)
|
|
43
|
-
ruby-progressbar (1.8.
|
|
44
|
-
serverengine (1.6.4)
|
|
45
|
-
sigdump (~> 0.2.2)
|
|
42
|
+
ruby-progressbar (1.8.1)
|
|
46
43
|
sigdump (0.2.4)
|
|
47
|
-
|
|
48
|
-
systemd-journal (1.2.
|
|
49
|
-
ffi (~> 1.9
|
|
44
|
+
string-scrub (0.0.5)
|
|
45
|
+
systemd-journal (1.2.3)
|
|
46
|
+
ffi (~> 1.9)
|
|
50
47
|
test-unit (2.5.5)
|
|
51
48
|
thread_safe (0.3.5)
|
|
52
49
|
tzinfo (1.2.2)
|
|
53
50
|
thread_safe (~> 0.1)
|
|
54
|
-
tzinfo-data (1.2016.
|
|
51
|
+
tzinfo-data (1.2016.10)
|
|
55
52
|
tzinfo (>= 1.0.0)
|
|
56
|
-
yajl-ruby (1.
|
|
53
|
+
yajl-ruby (1.3.0)
|
|
57
54
|
|
|
58
55
|
PLATFORMS
|
|
59
56
|
ruby
|
|
@@ -61,7 +58,8 @@ PLATFORMS
|
|
|
61
58
|
DEPENDENCIES
|
|
62
59
|
bundler (~> 1.10)
|
|
63
60
|
fluent-plugin-systemd!
|
|
64
|
-
|
|
61
|
+
fluentd (= 0.12.31)
|
|
62
|
+
rake
|
|
65
63
|
reevoocop
|
|
66
64
|
test-unit (~> 2.5)
|
|
67
65
|
|
data/README.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/reevoo/fluent-plugin-systemd) [](https://codeclimate.com/github/reevoo/fluent-plugin-systemd) [](https://rubygems.org/gems/fluent-plugin-systemd)
|
|
4
4
|
|
|
5
|
+
# Requirements <a name="requirements"></a>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|fluent-plugin-systemd|fluentd|ruby|
|
|
9
|
+
|----|----|----|
|
|
10
|
+
| 0.1.x | >= 0.14.11, < 2 | >= 2.1 |
|
|
11
|
+
| 0.0.x | ~> 0.12.0 | >= 1.9 |
|
|
12
|
+
|
|
13
|
+
## WARNING
|
|
14
|
+
this is the maintenance branch for the **0.0.x** series that supports fluentd
|
|
15
|
+
v0.12.x we plan to backport commits from master at least until td-agent is
|
|
16
|
+
based on fluentd v0.14
|
|
17
|
+
|
|
18
|
+
please install the [0.1.x release](https://github.com/reevoo/fluent-plugin-systemd)
|
|
19
|
+
if you are using fluentd v0.14 for the latest and greatest features
|
|
20
|
+
|
|
5
21
|
## Overview
|
|
6
22
|
|
|
7
23
|
**systemd** input plugin reads logs from the systemd journal
|
|
@@ -10,20 +26,16 @@
|
|
|
10
26
|
|
|
11
27
|
Simply use RubyGems:
|
|
12
28
|
|
|
13
|
-
gem install fluent-plugin-systemd -v 0.0.
|
|
14
|
-
|
|
15
|
-
or
|
|
16
|
-
|
|
17
|
-
fluent-gem install fluent-plugin-systemd -v 0.0.5
|
|
29
|
+
gem install fluent-plugin-systemd -v 0.0.6
|
|
18
30
|
|
|
19
31
|
or
|
|
20
32
|
|
|
21
|
-
td-agent-gem install fluent-plugin-systemd -v 0.0.
|
|
33
|
+
td-agent-gem install fluent-plugin-systemd -v 0.0.6
|
|
22
34
|
|
|
23
35
|
## Configuration
|
|
24
36
|
|
|
25
37
|
<source>
|
|
26
|
-
type systemd
|
|
38
|
+
@type systemd
|
|
27
39
|
path /var/log/journal
|
|
28
40
|
filters [{ "_SYSTEMD_UNIT": "kube-proxy.service" }]
|
|
29
41
|
pos_file kube-proxy.pos
|
|
@@ -5,13 +5,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "fluent-plugin-systemd"
|
|
8
|
-
spec.version = "0.0.
|
|
8
|
+
spec.version = "0.0.6"
|
|
9
9
|
spec.authors = ["Ed Robinson"]
|
|
10
10
|
spec.email = ["ed@reevoo.com"]
|
|
11
11
|
|
|
12
12
|
spec.summary = "Input plugin to read from systemd journal."
|
|
13
13
|
spec.description = "This is a fluentd input plugin. It reads logs from the systemd journal."
|
|
14
|
-
spec.homepage = "https://github.com/
|
|
14
|
+
spec.homepage = "https://github.com/reevoo/fluent-plugin-systemd"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.10"
|
|
22
|
-
spec.add_development_dependency "rake"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
23
|
spec.add_development_dependency "test-unit", "~> 2.5"
|
|
24
24
|
spec.add_development_dependency "reevoocop"
|
|
25
25
|
|
|
@@ -13,21 +13,18 @@ module Fluent
|
|
|
13
13
|
config_param :strip_underscores, :bool, default: false
|
|
14
14
|
config_param :tag, :string
|
|
15
15
|
|
|
16
|
-
attr_reader :tag
|
|
17
|
-
|
|
18
16
|
def configure(conf)
|
|
19
17
|
super
|
|
20
|
-
@pos_writer = PosWriter.new(
|
|
21
|
-
@journal = Systemd::Journal.new(path: path)
|
|
22
|
-
@
|
|
23
|
-
journal.filter(*filters)
|
|
18
|
+
@pos_writer = PosWriter.new(@pos_file)
|
|
19
|
+
@journal = Systemd::Journal.new(path: @path)
|
|
20
|
+
@journal.filter(*@filters)
|
|
24
21
|
seek
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
def start
|
|
28
25
|
super
|
|
29
26
|
@running = true
|
|
30
|
-
pos_writer.start
|
|
27
|
+
@pos_writer.start
|
|
31
28
|
@thread = Thread.new(&method(:run))
|
|
32
29
|
end
|
|
33
30
|
|
|
@@ -35,29 +32,37 @@ module Fluent
|
|
|
35
32
|
super
|
|
36
33
|
@running = false
|
|
37
34
|
@thread.join
|
|
38
|
-
pos_writer.shutdown
|
|
35
|
+
@pos_writer.shutdown
|
|
39
36
|
end
|
|
40
37
|
|
|
41
38
|
private
|
|
42
39
|
|
|
43
|
-
attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer, :strip_underscores, :read_from_head
|
|
44
|
-
|
|
45
40
|
def seek
|
|
46
|
-
|
|
41
|
+
seek_to(@pos_writer.cursor || read_from)
|
|
47
42
|
rescue Systemd::JournalError
|
|
48
43
|
log.warn("Could not seek to cursor #{@pos_writer.cursor} found in pos file: #{@pos_writer.path}")
|
|
49
|
-
|
|
44
|
+
seek_to(read_from)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# according to https://github.com/ledbettj/systemd-journal/issues/64#issuecomment-271056644
|
|
48
|
+
# and https://bugs.freedesktop.org/show_bug.cgi?id=64614, after doing a seek(:tail),
|
|
49
|
+
# you must move back in such a way that the next move_next will return the last
|
|
50
|
+
# record
|
|
51
|
+
def seek_to(pos)
|
|
52
|
+
@journal.seek(pos)
|
|
53
|
+
return unless pos == :tail
|
|
54
|
+
@journal.move(-2)
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
def read_from
|
|
53
|
-
read_from_head ? :head : :tail
|
|
58
|
+
@read_from_head ? :head : :tail
|
|
54
59
|
end
|
|
55
60
|
|
|
56
61
|
def run
|
|
57
62
|
Thread.current.abort_on_exception = true
|
|
58
63
|
watch do |entry|
|
|
59
64
|
begin
|
|
60
|
-
router.emit(tag, entry.realtime_timestamp.to_i, formatted(entry))
|
|
65
|
+
router.emit(@tag, entry.realtime_timestamp.to_i, formatted(entry))
|
|
61
66
|
rescue => e
|
|
62
67
|
log.error("Exception emitting record: #{e}")
|
|
63
68
|
end
|
|
@@ -65,16 +70,16 @@ module Fluent
|
|
|
65
70
|
end
|
|
66
71
|
|
|
67
72
|
def formatted(entry)
|
|
68
|
-
return entry.to_h unless strip_underscores
|
|
73
|
+
return entry.to_h unless @strip_underscores
|
|
69
74
|
Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ""), v] }]
|
|
70
75
|
end
|
|
71
76
|
|
|
72
77
|
def watch
|
|
73
|
-
while running
|
|
74
|
-
next unless journal.wait(1_000_000)
|
|
75
|
-
while journal.move_next && running
|
|
76
|
-
yield journal.current_entry
|
|
77
|
-
pos_writer.update(journal.cursor)
|
|
78
|
+
while @running
|
|
79
|
+
next unless @journal.wait(1_000_000)
|
|
80
|
+
while @journal.move_next && @running
|
|
81
|
+
yield @journal.current_entry
|
|
82
|
+
@pos_writer.update(@journal.cursor)
|
|
78
83
|
end
|
|
79
84
|
end
|
|
80
85
|
end
|
|
@@ -5,53 +5,53 @@ module Fluent
|
|
|
5
5
|
class PosWriter
|
|
6
6
|
def initialize(pos_file)
|
|
7
7
|
@path = pos_file
|
|
8
|
+
@lock = Mutex.new
|
|
9
|
+
@cursor = nil
|
|
10
|
+
@written_cursor = nil
|
|
8
11
|
setup
|
|
9
12
|
end
|
|
10
13
|
|
|
11
14
|
attr_reader :cursor, :path
|
|
12
15
|
|
|
13
16
|
def start
|
|
14
|
-
return unless path
|
|
17
|
+
return unless @path
|
|
15
18
|
@running = true
|
|
16
19
|
@thread = Thread.new(&method(:work))
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def shutdown
|
|
20
|
-
return unless path
|
|
23
|
+
return unless @path
|
|
21
24
|
@running = false
|
|
22
|
-
thread.join
|
|
25
|
+
@thread.join
|
|
23
26
|
write_pos
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
def update(c)
|
|
27
|
-
return unless path
|
|
28
|
-
lock.synchronize { @cursor = c }
|
|
30
|
+
return unless @path
|
|
31
|
+
@lock.synchronize { @cursor = c }
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
private
|
|
32
35
|
|
|
33
|
-
attr_reader :lock, :thread, :running
|
|
34
|
-
|
|
35
36
|
def setup
|
|
36
|
-
return unless path
|
|
37
|
-
@
|
|
38
|
-
@cursor = IO.read(path).chomp if File.exist?(path)
|
|
37
|
+
return unless @path && File.exist?(@path)
|
|
38
|
+
@cursor = IO.read(@path).chomp
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def work
|
|
42
|
-
while running
|
|
42
|
+
while @running
|
|
43
43
|
write_pos
|
|
44
44
|
sleep 1
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def write_pos
|
|
49
|
-
lock.synchronize do
|
|
50
|
-
if @written_cursor != cursor
|
|
51
|
-
file = File.open(path, "w+")
|
|
52
|
-
file.print cursor
|
|
49
|
+
@lock.synchronize do
|
|
50
|
+
if @written_cursor != @cursor
|
|
51
|
+
file = File.open(@path, "w+")
|
|
52
|
+
file.print @cursor
|
|
53
53
|
file.close
|
|
54
|
-
@written_cursor = cursor
|
|
54
|
+
@written_cursor = @cursor
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
Binary file
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-systemd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ed Robinson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: test-unit
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,7 +111,9 @@ files:
|
|
|
111
111
|
- lib/fluent/plugin/systemd/pos_writer.rb
|
|
112
112
|
- pkg/fluent-plugin-systemd-0.0.3.gem
|
|
113
113
|
- pkg/fluent-plugin-systemd-0.0.4.gem
|
|
114
|
-
|
|
114
|
+
- pkg/fluent-plugin-systemd-0.0.5.gem
|
|
115
|
+
- pkg/fluent-plugin-systemd-0.1.0.gem
|
|
116
|
+
homepage: https://github.com/reevoo/fluent-plugin-systemd
|
|
115
117
|
licenses:
|
|
116
118
|
- MIT
|
|
117
119
|
metadata: {}
|