fluent-plugin-mysql-status 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +173 -0
- data/Rakefile +10 -0
- data/fluent-plugin-mysql-status.gemspec +26 -0
- data/lib/fluent/plugin/in_mysql_status.rb +243 -0
- data/lib/fluent/plugin/mysql_status/version.rb +5 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_in_mysql_status.rb +114 -0
- data/test/test.sql +3 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 068bb41e6821684fbbfe794d73c091f89fa60525
|
4
|
+
data.tar.gz: 907ca182d8db0739c9cfad713157cf733baca1d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27f8cb79fc23cc083a5d03f8b678c07c1ef518fb6cd3b36a4bfc3166b089a63456b3611732ef57f5f677b87db2e425bfde50396eb950d180b08683f1f652c420
|
7
|
+
data.tar.gz: 14722355dcdcf6aa7f98284008a854f34ac0c1762cce80e1172e4c515877809f72551efa39ff44562468723828bc9cf2893d3258de2ff847f1643a330c44c296
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (C) 2016- gumi Inc.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
# fluent-plugin-mysql-status
|
2
|
+
|
3
|
+
[fluentd](http://fluentd.org) input plugin that monitor status of MySQL Server.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/gumi/fluent-plugin-mysql-status)
|
6
|
+
[](https://codeclimate.com/github/gumi/fluent-plugin-mysql-status)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Install with gem or fluent-gem command as:
|
11
|
+
|
12
|
+
```
|
13
|
+
# for fluentd
|
14
|
+
$ gem install fluent-plugin-mysql-status
|
15
|
+
|
16
|
+
# for td-agent
|
17
|
+
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-mysql-status
|
18
|
+
```
|
19
|
+
|
20
|
+
## Configuration
|
21
|
+
|
22
|
+
```
|
23
|
+
<source>
|
24
|
+
type mysql_status
|
25
|
+
tag mysql_status # Required
|
26
|
+
|
27
|
+
host 127.0.0.1 # Optional (default: localhost)
|
28
|
+
port 3306 # Optional (default: 3306)
|
29
|
+
username ham # Optional (default: root)
|
30
|
+
password egg # Optional (default: nopassword)
|
31
|
+
database spam # Optional (default: unselected database)
|
32
|
+
encoding utf8 # Optional (default: utf8)
|
33
|
+
|
34
|
+
comment Fluent::MySQLStatusInput # Optional (default: Fluent::MySQLStatusInput)
|
35
|
+
|
36
|
+
<query>
|
37
|
+
type processlist # Required if path and string is undefined
|
38
|
+
tag processlist # Required
|
39
|
+
interval 1 # Optional (default: 10)
|
40
|
+
</query>
|
41
|
+
|
42
|
+
<query>
|
43
|
+
path /path/to/statements_with_errors.sql # Required if type and string is undefined
|
44
|
+
tag errors
|
45
|
+
</query>
|
46
|
+
|
47
|
+
<query>
|
48
|
+
string SHOW STATUS # Required if type and path is undefined
|
49
|
+
tag status
|
50
|
+
omit_variable_name_from_record true # Optional (default: false)
|
51
|
+
clump_records true # Optional (default: false)
|
52
|
+
</query>
|
53
|
+
|
54
|
+
<query>
|
55
|
+
string SELECT DIGEST_TEXT FROM performance_schema.events_statements_summary_by_digest
|
56
|
+
tag summary
|
57
|
+
clump_records true # Optional (default: false)
|
58
|
+
clumped_records_key records # Optional (default: records)
|
59
|
+
</query>
|
60
|
+
</source>
|
61
|
+
```
|
62
|
+
|
63
|
+
Since this plugin runs multiple queries with a single connection, it doesn't put too much load on the MySQL server.
|
64
|
+
However, since queries run sequentially, slow queries hinder other queries from running.
|
65
|
+
|
66
|
+
### query.type
|
67
|
+
|
68
|
+
The following types are available.
|
69
|
+
|
70
|
+
- processlist - SHOW FULL PROCESSLIST
|
71
|
+
- status - SHOW OPEN TABLES
|
72
|
+
- open_tables - SHOW /*!50002 GLOBAL */ STATUS
|
73
|
+
|
74
|
+
### query.string
|
75
|
+
|
76
|
+
If you don't like the types mentioned above, you can write a query freely.
|
77
|
+
|
78
|
+
### query.path
|
79
|
+
|
80
|
+
If your query is long, write the query to a file and set the file path to this setting.
|
81
|
+
|
82
|
+
### tag + query.tag
|
83
|
+
|
84
|
+
If you set the following configuration:
|
85
|
+
|
86
|
+
```
|
87
|
+
<source>
|
88
|
+
tag ham
|
89
|
+
|
90
|
+
<query>
|
91
|
+
tag egg
|
92
|
+
</query>
|
93
|
+
</source>
|
94
|
+
```
|
95
|
+
|
96
|
+
This plugin make the following tag:
|
97
|
+
|
98
|
+
```
|
99
|
+
ham.egg
|
100
|
+
```
|
101
|
+
|
102
|
+
### query.interval
|
103
|
+
|
104
|
+
Set the interval at which the query runs in seconds.
|
105
|
+
|
106
|
+
### query.omit_variable_name_from_record
|
107
|
+
|
108
|
+
If the result of the query is in the following format:
|
109
|
+
|
110
|
+
```
|
111
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam: {'Variable_name': 'ham', 'Value': 'egg'}
|
112
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam: {'Variable_name': 'foo', 'Value': 'bar'}
|
113
|
+
```
|
114
|
+
|
115
|
+
Setting this to true results in the following result:
|
116
|
+
|
117
|
+
```
|
118
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam.ham: 'egg'
|
119
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam.foo: 'bar'
|
120
|
+
```
|
121
|
+
|
122
|
+
### query.clump_records
|
123
|
+
|
124
|
+
If the result of the query is in the following format:
|
125
|
+
|
126
|
+
```
|
127
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam: {'ham': 1, 'egg': 2}
|
128
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam: {'ham': 3, 'egg': 4}
|
129
|
+
```
|
130
|
+
|
131
|
+
Setting this to true results in the following result:
|
132
|
+
|
133
|
+
```
|
134
|
+
2016-12-23 23:09:56 +0900 mysql_status.spam: {'records': [{'ham': 1, 'egg': 2}, {'ham': 3, 'egg': 4}]}
|
135
|
+
```
|
136
|
+
|
137
|
+
### query.clumped_records_key
|
138
|
+
|
139
|
+
Set the key name to clump the records.
|
140
|
+
|
141
|
+
### comment
|
142
|
+
|
143
|
+
This setting is added as a comment to all queries.
|
144
|
+
|
145
|
+
If you set the following configuration:
|
146
|
+
|
147
|
+
```
|
148
|
+
<source>
|
149
|
+
comment This query was ran by fluentd
|
150
|
+
|
151
|
+
<query>
|
152
|
+
string SELECT spam FROM ham.egg
|
153
|
+
</query>
|
154
|
+
|
155
|
+
<query>
|
156
|
+
string SELECT foo FROM bar.baz
|
157
|
+
</query>
|
158
|
+
</source>
|
159
|
+
```
|
160
|
+
|
161
|
+
This plugin executes the following queries:
|
162
|
+
|
163
|
+
```
|
164
|
+
SELECT spam FROM ham.egg /* This query was ran by fluentd */
|
165
|
+
SELECT foo FROM bar.baz /* This query was ran by fluentd */
|
166
|
+
```
|
167
|
+
|
168
|
+
## Copyright
|
169
|
+
|
170
|
+
- Copyright
|
171
|
+
- Copyright (C) 2016- gumi Inc.
|
172
|
+
- License
|
173
|
+
- Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fluent/plugin/mysql_status/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-mysql-status"
|
8
|
+
spec.version = Fluent::MySQLStatus::VERSION
|
9
|
+
spec.authors = ["IKUTA Masahito"]
|
10
|
+
spec.email = ["masahito.ikuta@gu3.co.jp"]
|
11
|
+
spec.summary = %q{Fluentd input plugin that monitor status of MySQL Server.}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "http://github.com/gumi/fluent-plugin-mysql-status"
|
14
|
+
spec.license = "APLv2"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "test-unit", ["~> 3.0", "~> 3.1"]
|
23
|
+
|
24
|
+
spec.add_dependency "fluentd", ">= 0.10.55"
|
25
|
+
spec.add_dependency "mysql2", "~> 0.3.11"
|
26
|
+
end
|
@@ -0,0 +1,243 @@
|
|
1
|
+
require 'mysql2'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class MySQLStatusInput < Input
|
5
|
+
Plugin.register_input('mysql_status', self)
|
6
|
+
|
7
|
+
config_param :tag, :string
|
8
|
+
|
9
|
+
config_param :host, :string, :default => 'localhost'
|
10
|
+
config_param :port, :integer, :default => 3306
|
11
|
+
config_param :username, :string, :default => 'root'
|
12
|
+
config_param :password, :string, :default => nil
|
13
|
+
config_param :database, :string, :default => nil
|
14
|
+
config_param :encoding, :string, :default => 'utf8'
|
15
|
+
|
16
|
+
config_param :comment, :string, :default => 'Fluent::MySQLStatusInput'
|
17
|
+
|
18
|
+
attr_reader :queries
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
@queries = []
|
23
|
+
end
|
24
|
+
|
25
|
+
def configure(conf)
|
26
|
+
super
|
27
|
+
|
28
|
+
conf.elements.select {|element|
|
29
|
+
element.name == 'query'
|
30
|
+
}.each do |element|
|
31
|
+
tag = element['tag'] or raise ConfigError, "Missing 'tag' parameter on <query> directive"
|
32
|
+
string, default = configure_query_string(element)
|
33
|
+
interval = element['interval'] || 10
|
34
|
+
|
35
|
+
omit_variable_name_from_record, clump_records = [
|
36
|
+
'omit_variable_name_from_record', 'clump_records',
|
37
|
+
].map do |key|
|
38
|
+
configure_query_format_flag(element, key, default)
|
39
|
+
end
|
40
|
+
|
41
|
+
clumped_records_key = element['clumped_records_key'] || 'records'
|
42
|
+
|
43
|
+
@queries << {
|
44
|
+
:tag => tag,
|
45
|
+
:string => string,
|
46
|
+
:interval => Integer(interval),
|
47
|
+
:omit_variable_name_from_record => omit_variable_name_from_record,
|
48
|
+
:clump_records => clump_records,
|
49
|
+
:clumped_records_key => clumped_records_key,
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def start
|
55
|
+
@watcher = Thread.new(&method(:watch))
|
56
|
+
end
|
57
|
+
|
58
|
+
def shutdown
|
59
|
+
@watcher.kill
|
60
|
+
end
|
61
|
+
|
62
|
+
def watch
|
63
|
+
client = ensure_connect()
|
64
|
+
counter = generate_counter()
|
65
|
+
loop do
|
66
|
+
begin
|
67
|
+
emit_queries(client, counter.next())
|
68
|
+
rescue => e
|
69
|
+
$log.error e.message
|
70
|
+
client = ensure_connect()
|
71
|
+
end
|
72
|
+
sleep 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def configure_query_string(conf)
|
79
|
+
type = conf['type']
|
80
|
+
path = conf['path']
|
81
|
+
string = conf['string']
|
82
|
+
|
83
|
+
if type and path or type and string or path and string
|
84
|
+
raise ConfigError, "'type', 'path' and 'string' parameter can't be defined together."
|
85
|
+
end
|
86
|
+
|
87
|
+
if type
|
88
|
+
return case type
|
89
|
+
when 'processlist'
|
90
|
+
['SHOW FULL PROCESSLIST', false]
|
91
|
+
when 'open_tables'
|
92
|
+
['SHOW OPEN TABLES', false]
|
93
|
+
when 'status'
|
94
|
+
['SHOW /*!50002 GLOBAL */ STATUS', true]
|
95
|
+
else
|
96
|
+
raise ConfigError, "Missing 'type' parameter on <query> directive"
|
97
|
+
end
|
98
|
+
elsif path
|
99
|
+
return [File.read(path), false]
|
100
|
+
elsif string
|
101
|
+
return [string, false]
|
102
|
+
else
|
103
|
+
raise ConfigError, "Missing 'type' parameter on <query> directive"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def configure_query_format_flag(conf, key, default)
|
108
|
+
case conf[key]
|
109
|
+
when nil
|
110
|
+
default
|
111
|
+
when 'true'
|
112
|
+
true
|
113
|
+
else
|
114
|
+
false
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def ensure_connect
|
119
|
+
intervals = generate_intervals()
|
120
|
+
begin
|
121
|
+
return Mysql2::Client.new({
|
122
|
+
:host => @host,
|
123
|
+
:port => @port,
|
124
|
+
:username => @username,
|
125
|
+
:password => @password,
|
126
|
+
:database => @database,
|
127
|
+
:encoding => @encoding,
|
128
|
+
# :reconnect => true,
|
129
|
+
})
|
130
|
+
rescue => e
|
131
|
+
$log.error e.message
|
132
|
+
sleep intervals.next()
|
133
|
+
retry
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def generate_intervals
|
138
|
+
return Enumerator.new do |yielder|
|
139
|
+
temp, interval = 0, 1
|
140
|
+
loop do
|
141
|
+
if 55 <= interval
|
142
|
+
yielder << 60
|
143
|
+
else
|
144
|
+
temp, interval = interval, temp + interval
|
145
|
+
yielder << interval
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def generate_counter
|
152
|
+
return Enumerator.new do |yielder|
|
153
|
+
counter = 0
|
154
|
+
loop do
|
155
|
+
counter += 1
|
156
|
+
yielder << counter
|
157
|
+
if 86400 <= counter
|
158
|
+
counter = 0
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def emit_queries(client, counter)
|
165
|
+
@queries.each do |query|
|
166
|
+
next unless can_emit?(counter, query[:interval])
|
167
|
+
result = run_query(client, query[:string]) or next
|
168
|
+
if query[:omit_variable_name_from_record]
|
169
|
+
omit_and_emit(query, result)
|
170
|
+
else
|
171
|
+
emit(query, result)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def can_emit?(counter, interval)
|
177
|
+
return counter % interval == 0
|
178
|
+
end
|
179
|
+
|
180
|
+
def run_query(client, query)
|
181
|
+
begin
|
182
|
+
return client.query("#{query} /* #{@comment} */", :cast => false, :cache_rows => false)
|
183
|
+
rescue Mysql2::Error => e
|
184
|
+
raise if [nil, 1040, 1053, 2002, 2003, 2006, 2013].include?(e.error_number)
|
185
|
+
$log.error %Q(query: "#{query}" reason: "#{e.message}")
|
186
|
+
return nil
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def emit(query, result)
|
191
|
+
tag = make_tag(query[:tag])
|
192
|
+
time = Engine.now
|
193
|
+
|
194
|
+
records = []
|
195
|
+
result.each do |row|
|
196
|
+
record = {}
|
197
|
+
row.each do |key, value|
|
198
|
+
record[key] = format(value)
|
199
|
+
end
|
200
|
+
|
201
|
+
if query[:clump_records]
|
202
|
+
records << record
|
203
|
+
else
|
204
|
+
router.emit(tag, time, record)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
if query[:clump_records]
|
209
|
+
router.emit(tag, time, {query[:clumped_records_key] => records})
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def omit_and_emit(query, result)
|
214
|
+
tag = make_tag(query[:tag])
|
215
|
+
time = Engine.now
|
216
|
+
|
217
|
+
record = {}
|
218
|
+
result.each do |row|
|
219
|
+
key = row.fetch('Variable_name')
|
220
|
+
value = format(row.fetch('Value'))
|
221
|
+
|
222
|
+
if query[:clump_records]
|
223
|
+
record[key] = value
|
224
|
+
else
|
225
|
+
emit_tag = [tag, key].join('.')
|
226
|
+
router.emit(emit_tag, time, value)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
if query[:clump_records]
|
231
|
+
router.emit(tag, time, record)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def make_tag(tag_suffix)
|
236
|
+
return [@tag, tag_suffix].join('.')
|
237
|
+
end
|
238
|
+
|
239
|
+
def format(value)
|
240
|
+
return Integer(value) rescue Float(value) rescue value
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
require 'fluent/log'
|
17
|
+
require 'fluent/test'
|
18
|
+
|
19
|
+
$log = Fluent::Log.new(STDOUT, Fluent::Log::LEVEL_DEBUG)
|
20
|
+
|
21
|
+
unless defined?(Test::Unit::AssertionFailedError)
|
22
|
+
class Test::Unit::AssertionFailedError < StandardError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'fluent/plugin/in_mysql_status'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class MySQLStatusInputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
TAG = 'tag'
|
9
|
+
HOST = 'localhost'
|
10
|
+
PORT = 3306
|
11
|
+
USERNAME = 'user'
|
12
|
+
PASSWORD = 'pw'
|
13
|
+
DATABASE = 'test_db'
|
14
|
+
ENCODING = 'utf8'
|
15
|
+
COMMENT = 'Fluent::MySQLStatusInput'
|
16
|
+
|
17
|
+
PATH = File.expand_path('../../test.sql', __FILE__)
|
18
|
+
|
19
|
+
QUERIES = [
|
20
|
+
{
|
21
|
+
:tag => 'tag1',
|
22
|
+
:string => 'select * from test.test',
|
23
|
+
:interval => 10,
|
24
|
+
:omit_variable_name_from_record => false,
|
25
|
+
:clump_records => false,
|
26
|
+
:clumped_records_key => 'records',
|
27
|
+
},
|
28
|
+
{
|
29
|
+
:tag => 'tag2',
|
30
|
+
:string => 'SHOW FULL PROCESSLIST',
|
31
|
+
:interval => 5,
|
32
|
+
:omit_variable_name_from_record => false,
|
33
|
+
:clump_records => false,
|
34
|
+
:clumped_records_key => 'records',
|
35
|
+
},
|
36
|
+
{
|
37
|
+
:tag => 'tag3',
|
38
|
+
:string => 'SHOW OPEN TABLES',
|
39
|
+
:interval => 10,
|
40
|
+
:omit_variable_name_from_record => false,
|
41
|
+
:clump_records => true,
|
42
|
+
:clumped_records_key => 'results',
|
43
|
+
},
|
44
|
+
{
|
45
|
+
:tag => 'tag4',
|
46
|
+
:string => 'SHOW /*!50002 GLOBAL */ STATUS',
|
47
|
+
:interval => 10,
|
48
|
+
:omit_variable_name_from_record => true,
|
49
|
+
:clump_records => true,
|
50
|
+
:clumped_records_key => 'records',
|
51
|
+
},
|
52
|
+
{
|
53
|
+
:tag => 'tag5',
|
54
|
+
:string => File.read(PATH),
|
55
|
+
:interval => 10,
|
56
|
+
:omit_variable_name_from_record => false,
|
57
|
+
:clump_records => false,
|
58
|
+
:clumped_records_key => 'records',
|
59
|
+
},
|
60
|
+
]
|
61
|
+
|
62
|
+
CONFIG = %[
|
63
|
+
tag #{TAG}
|
64
|
+
host #{HOST}
|
65
|
+
username #{USERNAME}
|
66
|
+
password #{PASSWORD}
|
67
|
+
database #{DATABASE}
|
68
|
+
|
69
|
+
<query>
|
70
|
+
tag tag1
|
71
|
+
string select * from test.test
|
72
|
+
</query>
|
73
|
+
|
74
|
+
<query>
|
75
|
+
tag tag2
|
76
|
+
type processlist
|
77
|
+
interval 5
|
78
|
+
</query>
|
79
|
+
|
80
|
+
<query>
|
81
|
+
tag tag3
|
82
|
+
type open_tables
|
83
|
+
clump_records true
|
84
|
+
clumped_records_key results
|
85
|
+
</query>
|
86
|
+
|
87
|
+
<query>
|
88
|
+
tag tag4
|
89
|
+
type status
|
90
|
+
</query>
|
91
|
+
|
92
|
+
<query>
|
93
|
+
tag tag5
|
94
|
+
path #{PATH}
|
95
|
+
</query>
|
96
|
+
]
|
97
|
+
|
98
|
+
def create_driver(conf=CONFIG)
|
99
|
+
Fluent::Test::InputTestDriver.new(Fluent::MySQLStatusInput).configure(conf)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_configure
|
103
|
+
d = create_driver
|
104
|
+
assert_equal TAG, d.instance.tag
|
105
|
+
assert_equal HOST, d.instance.host
|
106
|
+
assert_equal PORT, d.instance.port
|
107
|
+
assert_equal USERNAME, d.instance.username
|
108
|
+
assert_equal PASSWORD, d.instance.password
|
109
|
+
assert_equal DATABASE, d.instance.database
|
110
|
+
assert_equal ENCODING, d.instance.encoding
|
111
|
+
assert_equal COMMENT, d.instance.comment
|
112
|
+
assert_equal QUERIES, d.instance.queries
|
113
|
+
end
|
114
|
+
end
|
data/test/test.sql
ADDED
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-mysql-status
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- IKUTA Masahito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3.1'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.1'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: fluentd
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.10.55
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.10.55
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: mysql2
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.3.11
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.3.11
|
75
|
+
description: Fluentd input plugin that monitor status of MySQL Server.
|
76
|
+
email:
|
77
|
+
- masahito.ikuta@gu3.co.jp
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- .gitignore
|
83
|
+
- .travis.yml
|
84
|
+
- Gemfile
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- fluent-plugin-mysql-status.gemspec
|
89
|
+
- lib/fluent/plugin/in_mysql_status.rb
|
90
|
+
- lib/fluent/plugin/mysql_status/version.rb
|
91
|
+
- test/helper.rb
|
92
|
+
- test/plugin/test_in_mysql_status.rb
|
93
|
+
- test/test.sql
|
94
|
+
homepage: http://github.com/gumi/fluent-plugin-mysql-status
|
95
|
+
licenses:
|
96
|
+
- APLv2
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.0.14
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Fluentd input plugin that monitor status of MySQL Server.
|
118
|
+
test_files:
|
119
|
+
- test/helper.rb
|
120
|
+
- test/plugin/test_in_mysql_status.rb
|
121
|
+
- test/test.sql
|