fluent-plugin-systemd 0.0.11 → 0.1.0

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
- SHA256:
3
- metadata.gz: 57f4a5c49f8863f8264615a1b0893fac23c32f7feb82c815934ff263eb235ba4
4
- data.tar.gz: 7613556c53faca8c867fde10119ab1e4207af816b7111cf8cea14b28a5c426ee
2
+ SHA1:
3
+ metadata.gz: 027149ee076af73b625bdf8dcd22dd25a7f0e833
4
+ data.tar.gz: b729df398f867f111fd1a3f188eb7298437195c4
5
5
  SHA512:
6
- metadata.gz: 49a2c2640a078b63a6addf9ca165003e33cde97e46b1485c1eb638efa6a2d8d63083096f63583ffe4c334402267ea5ea69f8dbed58697b7999d85ac9f71a1f69
7
- data.tar.gz: d86b77ebfa1cad517c5e607bf831a40f947da5bc4a62e94ee26c04a13a5b1d47ccb3194eeb5d7c5ee7172232e6ebfb6cbcd1fdde4b7b08044243d4a5b8a71bb9
6
+ metadata.gz: 979f117f454ba7a4d72ce0c62fa82fa5cae5c18be170443a4d77160c2b6f58b2f2c7de8032d6abda96b4070ef83bdb6bf94bd6746277b56984550af1157821ff
7
+ data.tar.gz: 8cbcef9a6b30dee72ee515140ede68aa7317d3c9b8d338bdb76c84897d5eae0030ba810f4b840e8d902b8aab9573d58cb81314d2e5eb5b2d71eff9b4da894a60
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-systemd (0.1.0)
5
+ fluentd (>= 0.14.11, < 2)
6
+ systemd-journal (~> 1.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.3.0)
12
+ astrolabe (1.3.1)
13
+ parser (~> 2.2)
14
+ cool.io (1.4.5)
15
+ ffi (1.9.14)
16
+ fluentd (0.14.11)
17
+ cool.io (~> 1.4.5)
18
+ http_parser.rb (>= 0.5.1, < 0.7.0)
19
+ msgpack (>= 0.7.0, < 2.0.0)
20
+ serverengine (>= 2.0.4, < 3.0.0)
21
+ sigdump (~> 0.2.2)
22
+ strptime (~> 0.1.7)
23
+ tzinfo (~> 1.0)
24
+ tzinfo-data (~> 1.0)
25
+ yajl-ruby (~> 1.0)
26
+ http_parser.rb (0.6.0)
27
+ msgpack (1.0.2)
28
+ parser (2.3.3.1)
29
+ ast (~> 2.2)
30
+ powerpack (0.0.9)
31
+ rainbow (2.2.1)
32
+ rake (10.5.0)
33
+ reevoocop (0.0.9)
34
+ rubocop (= 0.28.0)
35
+ rubocop (0.28.0)
36
+ astrolabe (~> 1.3)
37
+ parser (>= 2.2.0.pre.7, < 3.0)
38
+ powerpack (~> 0.0.6)
39
+ rainbow (>= 1.99.1, < 3.0)
40
+ ruby-progressbar (~> 1.4)
41
+ ruby-progressbar (1.8.1)
42
+ serverengine (2.0.4)
43
+ sigdump (~> 0.2.2)
44
+ sigdump (0.2.4)
45
+ strptime (0.1.9)
46
+ systemd-journal (1.2.3)
47
+ ffi (~> 1.9)
48
+ test-unit (2.5.5)
49
+ thread_safe (0.3.5)
50
+ tzinfo (1.2.2)
51
+ thread_safe (~> 0.1)
52
+ tzinfo-data (1.2016.10)
53
+ tzinfo (>= 1.0.0)
54
+ yajl-ruby (1.3.0)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ bundler (~> 1.10)
61
+ fluent-plugin-systemd!
62
+ rake
63
+ reevoocop
64
+ test-unit (~> 2.5)
65
+
66
+ BUNDLED WITH
67
+ 1.13.2
data/README.md CHANGED
@@ -2,22 +2,6 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/reevoo/fluent-plugin-systemd.svg?branch=master)](https://travis-ci.org/reevoo/fluent-plugin-systemd) [![Code Climate GPA](https://codeclimate.com/github/reevoo/fluent-plugin-systemd/badges/gpa.svg)](https://codeclimate.com/github/reevoo/fluent-plugin-systemd) [![Gem Version](https://badge.fury.io/rb/fluent-plugin-systemd.svg)](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
-
21
5
  ## Overview
22
6
 
23
7
  **systemd** input plugin reads logs from the systemd journal
@@ -26,11 +10,15 @@ if you are using fluentd v0.14 for the latest and greatest features
26
10
 
27
11
  Simply use RubyGems:
28
12
 
29
- gem install fluent-plugin-systemd -v 0.0.11
13
+ gem install fluent-plugin-systemd -v 0.1.0
30
14
 
31
15
  or
32
16
 
33
- td-agent-gem install fluent-plugin-systemd -v 0.0.11
17
+ fluent-gem install fluent-plugin-systemd -v 0.1.0
18
+
19
+ or
20
+
21
+ td-agent-gem install fluent-plugin-systemd -v 0.1.0
34
22
 
35
23
  ## Configuration
36
24
 
@@ -90,9 +78,17 @@ For systems with systemd installed you can run the tests against your installed
90
78
 
91
79
  Issues and pull requests welcome
92
80
 
81
+ ## Maintainer
82
+
83
+ * [Ed Robinson](https://github.com/errm)
84
+
93
85
  ## Contributors
94
86
 
95
- Many thanks to our brilliant contributors
87
+ Many thanks to our fantastic contributors
96
88
 
97
- * [jescarri](https://github.com/jescarri)
98
- * [mikekap](https://github.com/mikekap)
89
+ * [Jesus Rafael Carrillo](https://github.com/jescarri)
90
+ * [Mike Kaplinskiy](https://github.com/mikekap)
91
+ * [Sadayuki Furuhashi](https://github.com/frsyuki)
92
+ * [Richard Megginson](https://github.com/richm)
93
+ * [Masahiro Nakagawa](https://github.com/repeatedly)
94
+ * [Hiroshi Hatake](https://github.com/cosmo0920)
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "reevoocop/rake_task"
4
+ require "fileutils"
5
+
6
+ ReevooCop::RakeTask.new(:reevoocop)
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.test_files = Dir["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: "docker:test"
13
+ task build: "docker:test"
14
+ task default: :reevoocop
15
+
16
+ namespace :docker do
17
+ distros = [:ubuntu, :"tdagent-ubuntu", :"tdagent-centos"]
18
+ task test: distros
19
+
20
+ distros.each do |distro|
21
+ task distro do
22
+ puts "testing on #{distro}"
23
+ begin
24
+ FileUtils.cp("test/docker/Dockerfile.#{distro}", "Dockerfile")
25
+ sh "docker build ."
26
+ ensure
27
+ FileUtils.rm("Dockerfile")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-systemd"
8
+ spec.version = "0.1.0"
9
+ spec.authors = ["Ed Robinson"]
10
+ spec.email = ["ed@reevoo.com"]
11
+
12
+ spec.summary = "Input plugin to read from systemd journal."
13
+ spec.description = "This is a fluentd input plugin. It reads logs from the systemd journal."
14
+ spec.homepage = "https://github.com/reevoo/fluent-plugin-systemd"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = Dir["**/**"].reject { |f| f.match(/^(test|spec|features)\//) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "test-unit", "~> 2.5"
24
+ spec.add_development_dependency "reevoocop"
25
+
26
+ spec.add_runtime_dependency "fluentd", [">= 0.14.11", "< 2"]
27
+ spec.add_runtime_dependency "systemd-journal", "~> 1.2"
28
+ end
@@ -1,98 +1,84 @@
1
1
  require "systemd/journal"
2
- require "fluent/input"
2
+ require "fluent/plugin/input"
3
3
  require "fluent/plugin/systemd/pos_writer"
4
4
 
5
5
  module Fluent
6
- class SystemdInput < Input
7
- Fluent::Plugin.register_input("systemd", self)
6
+ module Plugin
7
+ class SystemdInput < Input
8
+ Fluent::Plugin.register_input("systemd", self)
8
9
 
9
- config_param :path, :string, default: "/var/log/journal"
10
- config_param :filters, :array, default: []
11
- config_param :pos_file, :string, default: nil
12
- config_param :read_from_head, :bool, default: false
13
- config_param :strip_underscores, :bool, default: false
14
- config_param :tag, :string
10
+ helpers :timer
15
11
 
16
- def configure(conf)
17
- super
18
- @pos_writer = PosWriter.new(@pos_file)
19
- end
12
+ config_param :path, :string, default: "/var/log/journal"
13
+ config_param :filters, :array, default: []
14
+ config_param :pos_file, :string, default: nil
15
+ config_param :read_from_head, :bool, default: false
16
+ config_param :strip_underscores, :bool, default: false
17
+ config_param :tag, :string
20
18
 
21
- def start
22
- super
23
- @running = true
24
- @pos_writer.start
25
- @thread = Thread.new(&method(:run))
26
- end
19
+ def configure(conf)
20
+ super
21
+ @pos_writer = PosWriter.new(@pos_file)
22
+ @journal = Systemd::Journal.new(path: @path)
23
+ @journal.filter(*@filters)
24
+ seek
25
+ end
27
26
 
28
- def shutdown
29
- super
30
- @running = false
31
- @thread.join
32
- @pos_writer.shutdown
33
- end
27
+ def start
28
+ super
29
+ @pos_writer.start
30
+ timer_execute(:in_systemd_emit_worker, 1, &method(:run))
31
+ end
34
32
 
35
- private
33
+ def shutdown
34
+ @pos_writer.shutdown
35
+ super
36
+ end
36
37
 
37
- def init_journal
38
- @journal.close if @journal
39
- @journal = Systemd::Journal.new(path: @path)
40
- @journal.filter(*@filters)
41
- seek
42
- end
38
+ private
43
39
 
44
- def seek
45
- seek_to(@pos_writer.cursor || read_from)
46
- rescue Systemd::JournalError
47
- log.warn("Could not seek to cursor #{@pos_writer.cursor} found in pos file: #{@pos_writer.path}")
48
- seek_to(read_from)
49
- end
40
+ def seek
41
+ seek_to(@pos_writer.cursor || read_from)
42
+ rescue Systemd::JournalError
43
+ log.warn("Could not seek to cursor #{@pos_writer.cursor} found in pos file: #{@pos_writer.path}")
44
+ seek_to(read_from)
45
+ end
50
46
 
51
- # according to https://github.com/ledbettj/systemd-journal/issues/64#issuecomment-271056644
52
- # and https://bugs.freedesktop.org/show_bug.cgi?id=64614, after doing a seek(:tail),
53
- # you must move back in such a way that the next move_next will return the last
54
- # record
55
- def seek_to(pos)
56
- @journal.seek(pos)
57
- return unless pos == :tail
58
- @journal.move(-2)
59
- end
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)
55
+ end
60
56
 
61
- def read_from
62
- @read_from_head ? :head : :tail
63
- end
57
+ def read_from
58
+ @read_from_head ? :head : :tail
59
+ end
64
60
 
65
- def run
66
- init_journal
67
- Thread.current.abort_on_exception = true
68
- watch do |entry|
69
- begin
70
- router.emit(@tag, entry.realtime_timestamp.to_i, formatted(entry))
71
- rescue => e # rubocop:disable Style/RescueStandardError
72
- log.error("Exception emitting record: #{e}")
61
+ def run
62
+ Thread.current.abort_on_exception = true
63
+ watch do |entry|
64
+ begin
65
+ router.emit(@tag, Fluent::EventTime.from_time(entry.realtime_timestamp), formatted(entry))
66
+ rescue => e
67
+ log.error("Exception emitting record: #{e}")
68
+ end
73
69
  end
74
70
  end
75
- end
76
71
 
77
- def formatted(entry)
78
- return entry.to_h unless @strip_underscores
79
- Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ""), v] }]
80
- end
72
+ def formatted(entry)
73
+ return entry.to_h unless @strip_underscores
74
+ Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ""), v] }]
75
+ end
81
76
 
82
- def watch
83
- while @running
84
- init_journal if @journal.wait(0) == :invalidate
85
- while @journal.move_next && @running
86
- begin
87
- yield @journal.current_entry
88
- rescue Systemd::JournalError => e
89
- log.warn("Error Parsing Journal: #{e.class}: #{e.message}")
90
- next
91
- end
77
+ def watch
78
+ while @journal.move_next
79
+ yield @journal.current_entry
92
80
  @pos_writer.update(@journal.cursor)
93
81
  end
94
- # prevent a loop of death
95
- sleep 1
96
82
  end
97
83
  end
98
84
  end
@@ -1,56 +1,59 @@
1
- require "fluent/input"
1
+ require "fluent/plugin/input"
2
2
 
3
3
  module Fluent
4
- class SystemdInput < Input
5
- class PosWriter
6
- def initialize(pos_file)
7
- @path = pos_file
8
- @lock = Mutex.new
9
- @cursor = nil
10
- @written_cursor = nil
11
- setup
12
- end
4
+ module Plugin
5
+ class SystemdInput < Input
6
+ class PosWriter
7
+ def initialize(pos_file)
8
+ @path = pos_file
9
+ @lock = Mutex.new
10
+ @cursor = nil
11
+ @written_cursor = nil
12
+ setup
13
+ end
13
14
 
14
- attr_reader :cursor, :path
15
+ attr_reader :cursor, :path
15
16
 
16
- def start
17
- return unless @path
18
- @running = true
19
- @thread = Thread.new(&method(:work))
20
- end
17
+ def start
18
+ return unless @path
19
+ @running = true
20
+ @thread = Thread.new(&method(:work))
21
+ end
21
22
 
22
- def shutdown
23
- return unless @path
24
- @running = false
25
- @thread.join
26
- write_pos
27
- end
23
+ def shutdown
24
+ return unless @path
25
+ @running = false
26
+ @thread.join
27
+ write_pos
28
+ end
28
29
 
29
- def update(cursor)
30
- @lock.synchronize { @cursor = cursor }
31
- end
30
+ def update(c)
31
+ return unless @path
32
+ @lock.synchronize { @cursor = c }
33
+ end
32
34
 
33
- private
35
+ private
34
36
 
35
- def setup
36
- return unless @path && File.exist?(@path)
37
- @cursor = IO.read(@path).chomp
38
- end
37
+ def setup
38
+ return unless @path && File.exist?(@path)
39
+ @cursor = IO.read(@path).chomp
40
+ end
39
41
 
40
- def work
41
- while @running
42
- write_pos
43
- sleep 1
42
+ def work
43
+ while @running
44
+ write_pos
45
+ sleep 1
46
+ end
44
47
  end
45
- end
46
48
 
47
- def write_pos
48
- @lock.synchronize do
49
- if @written_cursor != @cursor
50
- file = File.open(@path, "w+")
51
- file.print @cursor
52
- file.close
53
- @written_cursor = @cursor
49
+ def write_pos
50
+ @lock.synchronize do
51
+ if @written_cursor != @cursor
52
+ file = File.open(@path, "w+")
53
+ file.print @cursor
54
+ file.close
55
+ @written_cursor = @cursor
56
+ end
54
57
  end
55
58
  end
56
59
  end
Binary file
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.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,61 +39,67 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: reevoocop
42
+ name: test-unit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.5'
55
55
  - !ruby/object:Gem::Dependency
56
- name: test-unit
56
+ name: reevoocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.5'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '2.5'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fluentd
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.14.11
76
+ - - "<"
74
77
  - !ruby/object:Gem::Version
75
- version: '0.12'
78
+ version: '2'
76
79
  type: :runtime
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
- - - "~>"
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.14.11
86
+ - - "<"
81
87
  - !ruby/object:Gem::Version
82
- version: '0.12'
88
+ version: '2'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: systemd-journal
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: 1.3.2
95
+ version: '1.2'
90
96
  type: :runtime
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: 1.3.2
102
+ version: '1.2'
97
103
  description: This is a fluentd input plugin. It reads logs from the systemd journal.
98
104
  email:
99
105
  - ed@reevoo.com
@@ -101,10 +107,17 @@ executables: []
101
107
  extensions: []
102
108
  extra_rdoc_files: []
103
109
  files:
110
+ - Gemfile
111
+ - Gemfile.lock
104
112
  - LICENCE
105
113
  - README.md
114
+ - Rakefile
115
+ - fluent-plugin-systemd.gemspec
106
116
  - lib/fluent/plugin/in_systemd.rb
107
117
  - lib/fluent/plugin/systemd/pos_writer.rb
118
+ - pkg/fluent-plugin-systemd-0.0.3.gem
119
+ - pkg/fluent-plugin-systemd-0.0.4.gem
120
+ - pkg/fluent-plugin-systemd-0.0.5.gem
108
121
  homepage: https://github.com/reevoo/fluent-plugin-systemd
109
122
  licenses:
110
123
  - MIT
@@ -125,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
138
  version: '0'
126
139
  requirements: []
127
140
  rubyforge_project:
128
- rubygems_version: 2.7.6
141
+ rubygems_version: 2.4.5.1
129
142
  signing_key:
130
143
  specification_version: 4
131
144
  summary: Input plugin to read from systemd journal.