fluent-plugin-utmpx 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +7 -3
- data/CHANGELOG.md +4 -0
- data/fluent-plugin-utmpx.gemspec +3 -3
- data/lib/fluent/plugin/in_utmpx.rb +15 -3
- data/test/plugin/test_in_utmpx.rb +16 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d3cabe9c9f7865bfb0770959d26e8cca09addf1a8aa5ed33aa1aeda354bc69
|
4
|
+
data.tar.gz: 89b374d79e6c0d296b8dcfc2fe847e19f5354e407a4a36d18449e706f86d08ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d518632c6959910dccb11129beae4b19434920ff407d98606a066cd66555b5836e429f7b8fa4e7e3b94c1cb9a974869093a65a5832b6ad5a90ae7cecb6de0b43
|
7
|
+
data.tar.gz: 0f95670e7e8649b0a1b504a08d92a8f54da3e3f1365764c4c39c99a1eb3a026df569d0b48b2b76ba3a54ce1b94cd190bd5182f2a7c9b06c1e436da70c21d03fa
|
data/.github/workflows/main.yml
CHANGED
@@ -9,7 +9,8 @@ jobs:
|
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
11
|
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
12
|
-
|
12
|
+
fluentd: ['1.11.5', '1.12.2']
|
13
|
+
name: Ruby ${{ matrix.ruby }} Fluentd ${{ matrix.fluentd }}
|
13
14
|
steps:
|
14
15
|
- uses: actions/checkout@v2
|
15
16
|
- name: Set up Ruby
|
@@ -18,6 +19,9 @@ jobs:
|
|
18
19
|
ruby-version: ${{ matrix.ruby }}
|
19
20
|
- name: Run the default task
|
20
21
|
run: |
|
21
|
-
gem install
|
22
|
-
|
22
|
+
gem install fluentd -v ${{ matrix.fluentd }}
|
23
|
+
gem install rake -v 12.0
|
24
|
+
gem install webrick
|
25
|
+
rake build
|
26
|
+
gem install ./pkg/fluent-plugin-utmpx*.gem
|
23
27
|
TESTOPTS="--verbose" bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/fluent-plugin-utmpx.gemspec
CHANGED
@@ -3,12 +3,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-utmpx"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.5.0"
|
7
7
|
spec.authors = ["Kentaro Hayashi"]
|
8
8
|
spec.email = ["kenhys@gmail.com"]
|
9
9
|
|
10
|
-
spec.summary = %q{Fluentd
|
11
|
-
spec.description = %q{Fluentd
|
10
|
+
spec.summary = %q{Fluentd Input plugin to parse login records}
|
11
|
+
spec.description = %q{Fluentd Input plugin to parse /var/log/wtmp,/var/run/utmp}
|
12
12
|
spec.homepage = "https://github.com/fluent-plugins-nursery/fluent-plugin-utmpx"
|
13
13
|
spec.license = "Apache-2.0"
|
14
14
|
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
+
require "fluent/version"
|
16
17
|
require "fluent/plugin/input"
|
17
18
|
require "fluent/plugin/in_tail/position_file"
|
18
19
|
require 'fluent/variable_store'
|
@@ -22,6 +23,9 @@ Fluent::FileWrapper = File
|
|
22
23
|
|
23
24
|
module Fluent
|
24
25
|
module Plugin
|
26
|
+
|
27
|
+
TargetInfo = Struct.new(:path, :ino)
|
28
|
+
|
25
29
|
class UtmpxInput < Fluent::Plugin::Input
|
26
30
|
Fluent::Plugin.register_input("utmpx", self)
|
27
31
|
|
@@ -58,15 +62,23 @@ module Fluent
|
|
58
62
|
FileUtils.mkdir_p(pos_file_dir, mode: Fluent::DEFAULT_DIR_PERMISSION) unless Dir.exist?(pos_file_dir)
|
59
63
|
@pf_file = File.open(@pos_file, File::RDWR|File::CREAT|File::BINARY, Fluent::DEFAULT_FILE_PERMISSION)
|
60
64
|
@pf_file.sync = true
|
61
|
-
target_info =
|
62
|
-
|
65
|
+
target_info = TargetInfo.new(@path, Fluent::FileWrapper.stat(@path).ino)
|
66
|
+
if Gem::Version.new(Fluent::VERSION) < Gem::Version.new("1.12.0")
|
67
|
+
@pf = TailInput::PositionFile.load(@pf_file, logger: log)
|
68
|
+
else
|
69
|
+
@pf = TailInput::PositionFile.load(@pf_file, false, {target_info.path => target_info}, logger: log)
|
70
|
+
end
|
63
71
|
|
64
72
|
timer_execute(:execute_utmpx, @interval, &method(:refresh_watchers))
|
65
73
|
end
|
66
74
|
|
67
75
|
def refresh_watchers
|
68
76
|
@tail_position = Fluent::FileWrapper.stat(@path).size
|
69
|
-
|
77
|
+
if Gem::Version.new(Fluent::VERSION) < Gem::Version.new("1.12.0")
|
78
|
+
@pe = @pf[@path]
|
79
|
+
else
|
80
|
+
@pe = @pf[TargetInfo.new(@path, Fluent::FileWrapper.stat(@path).ino)]
|
81
|
+
end
|
70
82
|
return if (@tail_position - @pe.read_pos) == 0
|
71
83
|
|
72
84
|
if (@tail_position - @pe.read_pos) < 0
|
@@ -85,9 +85,14 @@ class UtmpxInputTest < Test::Unit::TestCase
|
|
85
85
|
create_wtmp
|
86
86
|
@tail_position = Fluent::FileWrapper.stat(wtmp_path).size
|
87
87
|
File.open(utmpx_pos_path, "w+") do |file|
|
88
|
-
target_info = Fluent::Plugin::
|
89
|
-
|
90
|
-
|
88
|
+
target_info = Fluent::Plugin::TargetInfo.new(wtmp_path, Fluent::FileWrapper.stat(wtmp_path).ino)
|
89
|
+
if Gem::Version.new(Fluent::VERSION) < Gem::Version.new("1.12.0")
|
90
|
+
@pf = Fluent::Plugin::TailInput::PositionFile.new(file, logger: nil)
|
91
|
+
@pe = @pf[wtmp_path]
|
92
|
+
else
|
93
|
+
@pf = Fluent::Plugin::TailInput::PositionFile.new(file, false, {wtmp_path => target_info}, logger: nil)
|
94
|
+
@pe = @pf[target_info]
|
95
|
+
end
|
91
96
|
@pe.update_pos(@tail_position)
|
92
97
|
end
|
93
98
|
d = create_driver(utmpx_config(wtmp_path))
|
@@ -104,9 +109,14 @@ class UtmpxInputTest < Test::Unit::TestCase
|
|
104
109
|
end
|
105
110
|
@tail_position = Fluent::FileWrapper.stat(wtmp_path).size
|
106
111
|
File.open(utmpx_pos_path, "w+") do |file|
|
107
|
-
target_info = Fluent::Plugin::
|
108
|
-
|
109
|
-
|
112
|
+
target_info = Fluent::Plugin::TargetInfo.new(wtmp_path, Fluent::FileWrapper.stat(wtmp_path).ino)
|
113
|
+
if Gem::Version.new(Fluent::VERSION) < Gem::Version.new("1.12.0")
|
114
|
+
@pf = Fluent::Plugin::TailInput::PositionFile.new(file, logger: nil)
|
115
|
+
@pe = @pf[wtmp_path]
|
116
|
+
else
|
117
|
+
@pf = Fluent::Plugin::TailInput::PositionFile.new(file, false, {wtmp_path => target_info}, logger: nil)
|
118
|
+
@pe = @pf[target_info]
|
119
|
+
end
|
110
120
|
@pe.update_pos(@tail_position)
|
111
121
|
end
|
112
122
|
File.open(wtmp_path, "w+") do |file|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-utmpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Hayashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: linux-utmpx
|
@@ -100,7 +100,7 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
-
description: Fluentd
|
103
|
+
description: Fluentd Input plugin to parse /var/log/wtmp,/var/run/utmp
|
104
104
|
email:
|
105
105
|
- kenhys@gmail.com
|
106
106
|
executables: []
|
@@ -146,7 +146,7 @@ requirements: []
|
|
146
146
|
rubygems_version: 3.1.4
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
|
-
summary: Fluentd
|
149
|
+
summary: Fluentd Input plugin to parse login records
|
150
150
|
test_files:
|
151
151
|
- test/fixtures/Makefile
|
152
152
|
- test/fixtures/alice_login.dump
|