fluent-plugin-zabbix 0.2.2 → 0.2.4
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 +5 -5
- data/fluent-plugin-zabbix.gemspec +4 -3
- data/lib/fluent/plugin/out_zabbix.rb +4 -3
- data/mockserver/go.mod +5 -0
- data/mockserver/go.sum +2 -0
- data/{test → mockserver}/mockserver.go +2 -1
- data/test/plugin/test_out_zabbix.rb +27 -23
- metadata +24 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 497e57af1beaf3860ad81af6bc382b98c0cd214df32e41135619f157a263a1f0
|
|
4
|
+
data.tar.gz: 2c7936b561ea53f172898bffe21223846659d7ec5b58c5b4cb1db1a7feb3692c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a57dabda7d0bd4d72e581eccd029edfd8d54421df0efb8f934a40dc98df2fbe7a83f98527d65c2a9c6b3a5cbffe351dbbca1390d941b5c06dbb56a64184c678c
|
|
7
|
+
data.tar.gz: aef02a1016229ec9b75503bd7e0fcebb4c356496e78f6850deec5e1fe1c774c1aedc2267b0b2676231bb6e23de8a6144a12770e9a09cde9db21b97f2bb4c6ed2
|
|
@@ -14,12 +14,13 @@ Gem::Specification.new do |gem|
|
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
15
15
|
gem.name = "fluent-plugin-zabbix"
|
|
16
16
|
gem.require_paths = ["lib"]
|
|
17
|
-
gem.version = "0.2.
|
|
17
|
+
gem.version = "0.2.4"
|
|
18
18
|
|
|
19
|
-
gem.add_runtime_dependency "fluentd", [">= 0.10", "<
|
|
19
|
+
gem.add_runtime_dependency "fluentd", [">= 0.10", "< 0.14"]
|
|
20
20
|
gem.add_runtime_dependency "yajl-ruby", "~> 1.0"
|
|
21
21
|
gem.add_runtime_dependency "fluent-mixin-config-placeholders", "~> 0.3"
|
|
22
22
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
|
23
|
-
gem.add_development_dependency "glint", "= 0.0
|
|
23
|
+
gem.add_development_dependency "glint", "= 0.1.0"
|
|
24
24
|
gem.add_development_dependency "test-unit", ">= 3.1.0"
|
|
25
|
+
gem.add_development_dependency "webrick"
|
|
25
26
|
end
|
|
@@ -4,6 +4,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
|
4
4
|
Fluent::Plugin.register_output('zabbix', self)
|
|
5
5
|
|
|
6
6
|
ZBXD = "ZBXD\x01"
|
|
7
|
+
ZBX_PROTO_VALUE_SENDER_DATA = 'sender data'
|
|
7
8
|
|
|
8
9
|
def initialize
|
|
9
10
|
super
|
|
@@ -85,7 +86,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
|
85
86
|
bulk.push({ :key => format_key(tag, key, record),
|
|
86
87
|
:value => format_value(record[key]),
|
|
87
88
|
:host => host,
|
|
88
|
-
:
|
|
89
|
+
:clock => time.to_i,
|
|
89
90
|
})
|
|
90
91
|
end
|
|
91
92
|
}
|
|
@@ -100,7 +101,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
|
100
101
|
bulk.push({ :key => format_key(tag, key, record),
|
|
101
102
|
:value => format_value(record[key]),
|
|
102
103
|
:host => host,
|
|
103
|
-
:
|
|
104
|
+
:clock => time.to_i,
|
|
104
105
|
})
|
|
105
106
|
end
|
|
106
107
|
}
|
|
@@ -154,7 +155,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
|
154
155
|
|
|
155
156
|
def send_to_zabbix(sock, time, bulk)
|
|
156
157
|
req = Yajl::Encoder.encode({
|
|
157
|
-
:request =>
|
|
158
|
+
:request => ZBX_PROTO_VALUE_SENDER_DATA,
|
|
158
159
|
:clock => time.to_i,
|
|
159
160
|
:data => bulk,
|
|
160
161
|
})
|
data/mockserver/go.mod
ADDED
data/mockserver/go.sum
ADDED
|
@@ -31,10 +31,11 @@ func main() {
|
|
|
31
31
|
func handler(req zabbix.TrapperRequest) (res zabbix.TrapperResponse, err error) {
|
|
32
32
|
for _, d := range req.Data {
|
|
33
33
|
line := fmt.Sprintf(
|
|
34
|
-
"host:%s\tkey:%s\tvalue:%s\n",
|
|
34
|
+
"host:%s\tkey:%s\tvalue:%s\tclock:%d\n",
|
|
35
35
|
d.Host,
|
|
36
36
|
d.Key,
|
|
37
37
|
d.Value,
|
|
38
|
+
d.Clock,
|
|
38
39
|
)
|
|
39
40
|
Output.Write([]byte(line))
|
|
40
41
|
}
|
|
@@ -3,7 +3,7 @@ require 'helper'
|
|
|
3
3
|
if ENV['LIVE_TEST']
|
|
4
4
|
require "glint"
|
|
5
5
|
require "tmpdir"
|
|
6
|
-
system "go
|
|
6
|
+
system "sh -c 'cd mockserver && go build mockserver.go'"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
class ZabbixOutputTest < Test::Unit::TestCase
|
|
@@ -12,7 +12,7 @@ class ZabbixOutputTest < Test::Unit::TestCase
|
|
|
12
12
|
if ENV['LIVE_TEST']
|
|
13
13
|
$dir = Dir.mktmpdir
|
|
14
14
|
$server = Glint::Server.new(10051, { :timeout => 3 }) do |port|
|
|
15
|
-
exec "./mockserver", $dir.to_s + "/trapper.log"
|
|
15
|
+
exec "./mockserver/mockserver", $dir.to_s + "/trapper.log"
|
|
16
16
|
end
|
|
17
17
|
$server.start
|
|
18
18
|
end
|
|
@@ -31,23 +31,24 @@ class ZabbixOutputTest < Test::Unit::TestCase
|
|
|
31
31
|
|
|
32
32
|
def test_write
|
|
33
33
|
d = create_driver
|
|
34
|
+
now = Time.now.to_i
|
|
34
35
|
if ENV['LIVE_TEST']
|
|
35
|
-
d.emit({"foo" => "test value of foo"})
|
|
36
|
-
d.emit({"bar" => "test value of bar"})
|
|
37
|
-
d.emit({"baz" => 123.4567 })
|
|
38
|
-
d.emit({"foo" => "yyy", "zabbix_host" => "alternative-hostname"})
|
|
39
|
-
d.emit({"f1" => 0.000001})
|
|
40
|
-
d.emit({"f2" => 0.01})
|
|
41
|
-
d.run
|
|
36
|
+
d.emit({"foo" => "test value of foo"}, now)
|
|
37
|
+
d.emit({"bar" => "test value of bar"}, now)
|
|
38
|
+
d.emit({"baz" => 123.4567 }, now)
|
|
39
|
+
d.emit({"foo" => "yyy", "zabbix_host" => "alternative-hostname"}, now)
|
|
40
|
+
d.emit({"f1" => 0.000001}, now)
|
|
41
|
+
d.emit({"f2" => 0.01}, now)
|
|
42
42
|
sleep 1
|
|
43
|
+
|
|
43
44
|
$server.stop
|
|
44
45
|
assert_equal open($dir + "/trapper.log").read, <<END
|
|
45
|
-
host:test_host key:test.foo value:test value of foo
|
|
46
|
-
host:test_host key:test.bar value:test value of bar
|
|
47
|
-
host:test_host key:test.baz value:123.4567
|
|
48
|
-
host:test_host key:test.foo value:yyy
|
|
49
|
-
host:test_host key:test.f1 value:0.0
|
|
50
|
-
host:test_host key:test.f2 value:0.01
|
|
46
|
+
host:test_host key:test.foo value:test value of foo clock:#{now}
|
|
47
|
+
host:test_host key:test.bar value:test value of bar clock:#{now}
|
|
48
|
+
host:test_host key:test.baz value:123.4567 clock:#{now}
|
|
49
|
+
host:test_host key:test.foo value:yyy clock:#{now}
|
|
50
|
+
host:test_host key:test.f1 value:0.0 clock:#{now}
|
|
51
|
+
host:test_host key:test.f2 value:0.01 clock:#{now}
|
|
51
52
|
END
|
|
52
53
|
end
|
|
53
54
|
end
|
|
@@ -77,30 +78,33 @@ END
|
|
|
77
78
|
|
|
78
79
|
def test_write_host_key
|
|
79
80
|
d = create_driver_host_key
|
|
81
|
+
now = Time.now.to_i
|
|
80
82
|
if ENV['LIVE_TEST']
|
|
81
|
-
d.emit({"foo" => "AAA" })
|
|
82
|
-
d.emit({"foo" => "BBB", "host" => "alternative-hostname"})
|
|
83
|
+
d.emit({"foo" => "AAA" }, now)
|
|
84
|
+
d.emit({"foo" => "BBB", "host" => "alternative-hostname"}, now)
|
|
83
85
|
d.run
|
|
84
86
|
sleep 1
|
|
87
|
+
|
|
85
88
|
$server.stop
|
|
86
89
|
assert_equal open($dir + "/trapper.log").read, <<END
|
|
87
|
-
host:test_host key:test.foo value:AAA
|
|
88
|
-
host:alternative-hostname key:test.foo value:BBB
|
|
90
|
+
host:test_host key:test.foo value:AAA clock:#{now}
|
|
91
|
+
host:alternative-hostname key:test.foo value:BBB clock:#{now}
|
|
89
92
|
END
|
|
90
93
|
end
|
|
91
94
|
end
|
|
92
95
|
|
|
93
96
|
def test_write_prefix_key
|
|
94
97
|
d = create_driver_prefix_key
|
|
98
|
+
now = Time.now.to_i
|
|
95
99
|
if ENV['LIVE_TEST']
|
|
96
|
-
d.emit({"foo" => "AAA"})
|
|
97
|
-
d.emit({"foo" => "BBB", "prefix" => "p"})
|
|
100
|
+
d.emit({"foo" => "AAA"}, now)
|
|
101
|
+
d.emit({"foo" => "BBB", "prefix" => "p"}, now)
|
|
98
102
|
d.run
|
|
99
103
|
sleep 1
|
|
100
104
|
$server.stop
|
|
101
105
|
assert_equal open($dir + "/trapper.log").read, <<END
|
|
102
|
-
host:test_host key:foo value:AAA
|
|
103
|
-
host:test_host key:p.foo value:BBB
|
|
106
|
+
host:test_host key:foo value:AAA clock:#{now}
|
|
107
|
+
host:test_host key:p.foo value:BBB clock:#{now}
|
|
104
108
|
END
|
|
105
109
|
end
|
|
106
110
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-zabbix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- FUJIWARA Shunichiro
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fluentd
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: '0.10'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '0.14'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: '0.10'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '0.14'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: yajl-ruby
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -78,14 +78,14 @@ dependencies:
|
|
|
78
78
|
requirements:
|
|
79
79
|
- - '='
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.0
|
|
81
|
+
version: 0.1.0
|
|
82
82
|
type: :development
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - '='
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.0
|
|
88
|
+
version: 0.1.0
|
|
89
89
|
- !ruby/object:Gem::Dependency
|
|
90
90
|
name: test-unit
|
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,6 +100,20 @@ dependencies:
|
|
|
100
100
|
- - ">="
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
102
|
version: 3.1.0
|
|
103
|
+
- !ruby/object:Gem::Dependency
|
|
104
|
+
name: webrick
|
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
type: :development
|
|
111
|
+
prerelease: false
|
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
103
117
|
description: Output data plugin to Zabbix
|
|
104
118
|
email:
|
|
105
119
|
- fujiwara.shunichiro@gmail.com
|
|
@@ -116,8 +130,10 @@ files:
|
|
|
116
130
|
- Rakefile
|
|
117
131
|
- fluent-plugin-zabbix.gemspec
|
|
118
132
|
- lib/fluent/plugin/out_zabbix.rb
|
|
133
|
+
- mockserver/go.mod
|
|
134
|
+
- mockserver/go.sum
|
|
135
|
+
- mockserver/mockserver.go
|
|
119
136
|
- test/helper.rb
|
|
120
|
-
- test/mockserver.go
|
|
121
137
|
- test/plugin/test_out_zabbix.rb
|
|
122
138
|
homepage: https://github.com/fujiwara/fluent-plugin-zabbix
|
|
123
139
|
licenses:
|
|
@@ -138,12 +154,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
154
|
- !ruby/object:Gem::Version
|
|
139
155
|
version: '0'
|
|
140
156
|
requirements: []
|
|
141
|
-
|
|
142
|
-
rubygems_version: 2.6.6
|
|
157
|
+
rubygems_version: 3.4.10
|
|
143
158
|
signing_key:
|
|
144
159
|
specification_version: 4
|
|
145
160
|
summary: Output data plugin to Zabbix (like zabbix_sender)
|
|
146
161
|
test_files:
|
|
147
162
|
- test/helper.rb
|
|
148
|
-
- test/mockserver.go
|
|
149
163
|
- test/plugin/test_out_zabbix.rb
|