fluent-plugin-zabbix 0.1.0 → 0.2.0
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/.travis.yml +2 -0
- data/README.md +3 -0
- data/fluent-plugin-zabbix.gemspec +3 -2
- data/lib/fluent/plugin/out_zabbix.rb +9 -3
- data/test/plugin/test_out_zabbix.rb +26 -0
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93794a2b1192debe9fee915e6dcb8db8edef4d9e
|
4
|
+
data.tar.gz: 711a95a9666e3542085646e7d5217d88f9c25689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35372f496277a1bb6f9b8fd386f105bfeba60cad7fbf1983023c4cecfa642171768e2335c2b1083c617c05993edcc53be0079673830a6ad995abfcba9d99c87e
|
7
|
+
data.tar.gz: fe044b53179e08ef1c0d7be1998aa3822694e8c8c19a62d4fe325c36054d46e2064c3812081d1949dd82038d098e8a4b7326e705751ad72079aed85fe4a84805
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -41,6 +41,9 @@ or, use `add_key_prefix`
|
|
41
41
|
name_key_pattern ^field
|
42
42
|
</match>
|
43
43
|
|
44
|
+
If `prefix_key` is specified, a value of record[prefix_key] will be used as key prefix.
|
45
|
+
|
46
|
+
|
44
47
|
If you want to specify the host(on zabbix) from record's value, use "host_key" directive.
|
45
48
|
|
46
49
|
tag:metrics {"zabbix_host":"myhostname", "metrics.field1":300, "metrics.field2":20}
|
@@ -7,15 +7,16 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.description = %q{Output data plugin to Zabbix}
|
8
8
|
gem.summary = %q{Output data plugin to Zabbix (like zabbix_sender)}
|
9
9
|
gem.homepage = "https://github.com/fujiwara/fluent-plugin-zabbix"
|
10
|
+
gem.license = "Apache-2.0"
|
10
11
|
|
11
12
|
gem.files = `git ls-files`.split($\)
|
12
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
15
|
gem.name = "fluent-plugin-zabbix"
|
15
16
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = "0.
|
17
|
+
gem.version = "0.2.0"
|
17
18
|
|
18
|
-
gem.add_runtime_dependency "fluentd", "
|
19
|
+
gem.add_runtime_dependency "fluentd", [">= 0.10", "< 2"]
|
19
20
|
gem.add_runtime_dependency "yajl-ruby", "~> 1.0"
|
20
21
|
gem.add_runtime_dependency "fluent-mixin-config-placeholders", "~> 0.3"
|
21
22
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
@@ -18,6 +18,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
18
18
|
config_param :name_keys, :string, :default => nil
|
19
19
|
config_param :name_key_pattern, :string, :default => nil
|
20
20
|
config_param :add_key_prefix, :string, :default => nil
|
21
|
+
config_param :prefix_key, :string, :default => nil
|
21
22
|
|
22
23
|
include Fluent::Mixin::ConfigPlaceholders
|
23
24
|
|
@@ -81,7 +82,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
81
82
|
bulk = []
|
82
83
|
@name_keys.each {|key|
|
83
84
|
if record[key]
|
84
|
-
bulk.push({ :key => format_key(tag, key),
|
85
|
+
bulk.push({ :key => format_key(tag, key, record),
|
85
86
|
:value => format_value(record[key]),
|
86
87
|
:host => host,
|
87
88
|
:time => time.to_i,
|
@@ -96,7 +97,7 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
96
97
|
bulk = []
|
97
98
|
record.keys.each {|key|
|
98
99
|
if @name_key_pattern.match(key) && record[key]
|
99
|
-
bulk.push({ :key => format_key(tag, key),
|
100
|
+
bulk.push({ :key => format_key(tag, key, record),
|
100
101
|
:value => format_value(record[key]),
|
101
102
|
:host => host,
|
102
103
|
:time => time.to_i,
|
@@ -123,7 +124,12 @@ class Fluent::ZabbixOutput < Fluent::Output
|
|
123
124
|
return host
|
124
125
|
end
|
125
126
|
|
126
|
-
def format_key(tag, key)
|
127
|
+
def format_key(tag, key, record)
|
128
|
+
if @prefix_key
|
129
|
+
if record[@prefix_key]
|
130
|
+
key = "#{record[@prefix_key]}.#{key}"
|
131
|
+
end
|
132
|
+
end
|
127
133
|
if @add_key_prefix
|
128
134
|
if @add_key_prefix == '${tag}'
|
129
135
|
"#{tag}.#{key}"
|
@@ -64,6 +64,17 @@ END
|
|
64
64
|
Fluent::Test::OutputTestDriver.new(Fluent::ZabbixOutput, tag).configure(conf)
|
65
65
|
end
|
66
66
|
|
67
|
+
CONFIG_PREFIX_KEY = %[
|
68
|
+
zabbix_server 127.0.0.1
|
69
|
+
host test_host
|
70
|
+
prefix_key prefix
|
71
|
+
name_keys foo, bar, baz
|
72
|
+
]
|
73
|
+
|
74
|
+
def create_driver_prefix_key(conf = CONFIG_PREFIX_KEY, tag='test')
|
75
|
+
Fluent::Test::OutputTestDriver.new(Fluent::ZabbixOutput, tag).configure(conf)
|
76
|
+
end
|
77
|
+
|
67
78
|
def test_write_host_key
|
68
79
|
d = create_driver_host_key
|
69
80
|
if ENV['LIVE_TEST']
|
@@ -75,6 +86,21 @@ END
|
|
75
86
|
assert_equal open($dir + "/trapper.log").read, <<END
|
76
87
|
host:test_host key:test.foo value:AAA
|
77
88
|
host:alternative-hostname key:test.foo value:BBB
|
89
|
+
END
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_write_prefix_key
|
94
|
+
d = create_driver_prefix_key
|
95
|
+
if ENV['LIVE_TEST']
|
96
|
+
d.emit({"foo" => "AAA"})
|
97
|
+
d.emit({"foo" => "BBB", "prefix" => "p"})
|
98
|
+
d.run
|
99
|
+
sleep 1
|
100
|
+
$server.stop
|
101
|
+
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
|
78
104
|
END
|
79
105
|
end
|
80
106
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-zabbix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FUJIWARA Shunichiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.10'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0.10'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: yajl-ruby
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +120,8 @@ files:
|
|
114
120
|
- test/mockserver.go
|
115
121
|
- test/plugin/test_out_zabbix.rb
|
116
122
|
homepage: https://github.com/fujiwara/fluent-plugin-zabbix
|
117
|
-
licenses:
|
123
|
+
licenses:
|
124
|
+
- Apache-2.0
|
118
125
|
metadata: {}
|
119
126
|
post_install_message:
|
120
127
|
rdoc_options: []
|