fluent-plugin-systemd 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b6d6e4b40b45d982559089fe27d8bdb85f0939c
4
- data.tar.gz: d35ef40bc4cf5d20861b44abb5341846ee064deb
3
+ metadata.gz: be742762901719c8b1ded7200a0daca9243088db
4
+ data.tar.gz: 03634c021da0ce9585eb111a52d0b126e86c7a86
5
5
  SHA512:
6
- metadata.gz: 565a8b206ec54735154ee6a66c53cfdd61fe8ed11d4ffb1c05bbc327b31b17b08c2adfac5e56f3fdcabef55cb50bc2eaf5459ce2256cb4750a5084c025efc56e
7
- data.tar.gz: 24deecc1bcc87379fb7e5461cd2ffb51350166a78722c4d4d4d3d4d2120ecda0f15cbfcdd58dc4b849e3cb7e9196a8588618080e1fc2a843cfcf299633121fa6
6
+ metadata.gz: 36a38856bcc70d5fa68e56f8e6514b8de79bc69719e7b265a8f570c629be5a9196bf9e8f459191b6234ba025ca3bcb47c0921c2ad148647683b1376055a5e415
7
+ data.tar.gz: 6500153a1b384a79522172abe10977a40a743aa3cd80157928638f4f076fdee2ba0c2c81b84f2e47ab9538b6ed95ee49fc99e28ecc8ba6594e4309bdd8914917
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+ gem "string-scrub", "0.0.5"
data/README.md CHANGED
@@ -10,15 +10,15 @@
10
10
 
11
11
  Simply use RubyGems:
12
12
 
13
- gem install fluent-plugin-systemd
13
+ gem install fluent-plugin-systemd -v 0.0.3
14
14
 
15
15
  or
16
16
 
17
- fluent-gem install fluent-plugin-systemd
17
+ fluent-gem install fluent-plugin-systemd -v 0.0.3
18
18
 
19
19
  or
20
20
 
21
- td-agent-gem install fluent-plugin-systemd
21
+ td-agent-gem install fluent-plugin-systemd -v 0.0.3
22
22
 
23
23
  ## Configuration
24
24
 
@@ -47,16 +47,20 @@ Path to pos file, stores the journald cursor. File is created if does not exist.
47
47
  **read_from_head**
48
48
 
49
49
  If true reads all available journal from head, otherwise starts reading from tail,
50
- ignored if pos file exists. Defaults to false.
50
+ ignored if pos file exists (and is valid). Defaults to false.
51
51
 
52
52
  **strip_underscores**
53
53
 
54
- If true strips underscores from the beginning of systemds field names.
54
+ If true strips underscores from the beginning of systemd field names.
55
55
  May be useful if outputting to kibana, as underscore prefixed fields are unindexed there.
56
56
 
57
57
  **tag**
58
58
 
59
- Required the tag for events generated by this input plugin.
59
+ _Required_ A tag that will be added to events generated by this input.
60
+
61
+ ## Example
62
+
63
+ For an example of a full working setup including the plugin, [take a look at](https://github.com/assemblyline/fluentd)
60
64
 
61
65
  ## Dependencies
62
66
 
@@ -64,9 +68,9 @@ This plugin depends on libsystemd
64
68
 
65
69
  ## Running the tests
66
70
 
67
- To run the tests simply run `rake test`
71
+ To run the tests with docker on several distros simply run `rake`
68
72
 
69
- For systems without systemd the tests are run in a docker container. So you will need docker or systemd installed to work on this.
73
+ For systems with systemd installed you can run the tests against your installed libsystemd with `rake test`
70
74
 
71
75
  ## Licence etc
72
76
 
data/Rakefile CHANGED
@@ -1,27 +1,31 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
- require 'reevoocop/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "reevoocop/rake_task"
4
+ require "fileutils"
4
5
 
5
6
  ReevooCop::RakeTask.new(:reevoocop)
6
7
 
7
- Rake::TestTask.new(:tests) do |t|
8
- t.test_files = Dir['test/**/test_*.rb']
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.test_files = Dir["test/**/test_*.rb"]
9
10
  end
10
11
 
11
- task default: :test
12
- task build: :test
13
- task tests: :reevoocop
12
+ task default: "docker:test"
13
+ task build: "docker:test"
14
+ task test: :reevoocop
14
15
 
15
16
  namespace :docker do
16
- task :test do
17
- sh 'docker build .'
18
- end
19
- end
17
+ distros = [:ubuntu, :"tdagent-ubuntu", :centos, :"tdagent-centos"]
18
+ task test: distros
20
19
 
21
- task :test do
22
- if system('which journalctl')
23
- Rake::Task['tests'].invoke
24
- else
25
- Rake::Task['docker:test'].invoke
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
26
30
  end
27
31
  end
@@ -1,29 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'fluent-plugin-systemd'
8
- spec.version = '0.0.2'
9
- spec.authors = ['Ed Robinson']
10
- spec.email = ['ed@reevoo.com']
7
+ spec.name = "fluent-plugin-systemd"
8
+ spec.version = "0.0.3"
9
+ spec.authors = ["Ed Robinson"]
10
+ spec.email = ["ed@reevoo.com"]
11
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/assemblyline/fluent-plugin-systemd'
15
- spec.license = 'MIT'
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/assemblyline/fluent-plugin-systemd"
15
+ spec.license = "MIT"
16
16
 
17
17
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
19
- spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
20
- spec.require_paths = ['lib']
18
+ spec.files = Dir["**/**"].reject { |f| f.match(/^(test|spec|features)\//) }
19
+ spec.require_paths = ["lib"]
21
20
 
22
- spec.add_development_dependency 'bundler', '~> 1.10'
23
- spec.add_development_dependency 'rake', '~> 10.4'
24
- spec.add_development_dependency 'test-unit', '~> 3.1'
25
- spec.add_development_dependency 'reevoocop'
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.4"
23
+ spec.add_development_dependency "test-unit", "~> 2.5"
24
+ spec.add_development_dependency "reevoocop"
26
25
 
27
- spec.add_runtime_dependency 'fluentd', '~> 0.12'
28
- spec.add_runtime_dependency 'systemd-journal', '~> 1.2'
26
+ spec.add_runtime_dependency "fluentd", "~> 0.12"
27
+ spec.add_runtime_dependency "systemd-journal", "~> 1.2"
29
28
  end
@@ -1,11 +1,11 @@
1
- require 'systemd/journal'
2
- require 'fluent/plugin/systemd/pos_writer'
1
+ require "systemd/journal"
2
+ require "fluent/plugin/systemd/pos_writer"
3
3
 
4
4
  module Fluent
5
5
  class SystemdInput < Input
6
- Fluent::Plugin.register_input('systemd', self)
6
+ Fluent::Plugin.register_input("systemd", self)
7
7
 
8
- config_param :path, :string, default: '/var/log/journal'
8
+ config_param :path, :string, default: "/var/log/journal"
9
9
  config_param :filters, :array, default: []
10
10
  config_param :pos_file, :string, default: nil
11
11
  config_param :read_from_head, :bool, default: false
@@ -16,11 +16,11 @@ module Fluent
16
16
 
17
17
  def configure(conf)
18
18
  super
19
- @pos_writer = PosWriter.new(conf['pos_file'])
19
+ @pos_writer = PosWriter.new(conf["pos_file"])
20
20
  @journal = Systemd::Journal.new(path: path)
21
+ @read_from_head = conf["read_from_head"]
21
22
  journal.filter(*filters)
22
- read_from = @pos_writer.cursor || (conf['read_from_head'] ? :head : :tail)
23
- journal.seek(read_from)
23
+ seek
24
24
  end
25
25
 
26
26
  def start
@@ -38,7 +38,18 @@ module Fluent
38
38
 
39
39
  private
40
40
 
41
- attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer, :strip_underscores
41
+ attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer, :strip_underscores, :read_from_head
42
+
43
+ def seek
44
+ journal.seek(@pos_writer.cursor || read_from)
45
+ rescue Systemd::JournalError
46
+ log.warn("Could not seek to cursor #{@pos_writer.cursor} found in pos file: #{@pos_writer.path}")
47
+ journal.seek(read_from)
48
+ end
49
+
50
+ def read_from
51
+ read_from_head ? :head : :tail
52
+ end
42
53
 
43
54
  def run
44
55
  watch do |entry|
@@ -48,7 +59,7 @@ module Fluent
48
59
 
49
60
  def formatted(entry)
50
61
  return entry.to_h unless strip_underscores
51
- Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ''), v] }]
62
+ Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ""), v] }]
52
63
  end
53
64
 
54
65
  def watch
@@ -6,7 +6,7 @@ module Fluent
6
6
  setup
7
7
  end
8
8
 
9
- attr_reader :cursor
9
+ attr_reader :cursor, :path
10
10
 
11
11
  def start
12
12
  return unless path
@@ -28,7 +28,7 @@ module Fluent
28
28
 
29
29
  private
30
30
 
31
- attr_reader :path, :lock, :thread, :running
31
+ attr_reader :lock, :thread, :running
32
32
 
33
33
  def setup
34
34
  return unless path
@@ -46,7 +46,7 @@ module Fluent
46
46
  def write_pos
47
47
  lock.synchronize do
48
48
  if @written_cursor != cursor
49
- file = File.open(path, 'w+')
49
+ file = File.open(path, "w+")
50
50
  file.print cursor
51
51
  file.close
52
52
  @written_cursor = cursor
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.1'
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: '3.1'
54
+ version: '2.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: reevoocop
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -101,9 +101,6 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".gitignore"
105
- - ".travis.yml"
106
- - Dockerfile
107
104
  - Gemfile
108
105
  - LICENCE
109
106
  - README.md
@@ -131,8 +128,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
128
  version: '0'
132
129
  requirements: []
133
130
  rubyforge_project:
134
- rubygems_version: 2.2.3
131
+ rubygems_version: 2.4.5.1
135
132
  signing_key:
136
133
  specification_version: 4
137
134
  summary: Input plugin to read from systemd journal.
138
135
  test_files: []
136
+ has_rdoc:
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- Gemfile.lock
@@ -1,4 +0,0 @@
1
- language: ruby
2
- sudo: required
3
- services:
4
- - docker
data/Dockerfile DELETED
@@ -1,21 +0,0 @@
1
- FROM quay.io/assemblyline/buildpack_deps:15.10
2
-
3
- RUN echo "deb http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu vivid main" | tee /etc/apt/sources.list.d/ruby-ng.list \
4
- && echo "deb-src http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu vivid main" | tee -a /etc/apt/sources.list.d/ruby-ng.list \
5
- && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6 \
6
- && apt-get update -q && apt-get install -qy --no-install-recommends \
7
- ruby2.2 \
8
- ruby2.2-dev \
9
- libsystemd-dev \
10
- && apt-get clean \
11
- && rm -rf /var/lib/apt/lists/* \
12
- && truncate -s 0 /var/log/*log \
13
- && gem install bundler
14
-
15
- WORKDIR /usr/local/src
16
-
17
- COPY Gemfile ./
18
- COPY fluent-plugin-systemd.gemspec ./
19
- RUN bundle install -j4 -r3
20
- COPY . .
21
- RUN bundle exec rake