fluent-plugin-glusterfs 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-glusterfs.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License.
62
+
63
+ Subject to the terms and conditions of this License, each Contributor hereby
64
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the Work and such
67
+ Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License.
70
+
71
+ Subject to the terms and conditions of this License, each Contributor hereby
72
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73
+ irrevocable (except as stated in this section) patent license to make, have
74
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75
+ such license applies only to those patent claims licensable by such Contributor
76
+ that are necessarily infringed by their Contribution(s) alone or by combination
77
+ of their Contribution(s) with the Work to which such Contribution(s) was
78
+ submitted. If You institute patent litigation against any entity (including a
79
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80
+ Contribution incorporated within the Work constitutes direct or contributory
81
+ patent infringement, then any patent licenses granted to You under this License
82
+ for that Work shall terminate as of the date such litigation is filed.
83
+
84
+ 4. Redistribution.
85
+
86
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
87
+ in any medium, with or without modifications, and in Source or Object form,
88
+ provided that You meet the following conditions:
89
+
90
+ You must give any other recipients of the Work or Derivative Works a copy of
91
+ this License; and
92
+ You must cause any modified files to carry prominent notices stating that You
93
+ changed the files; and
94
+ You must retain, in the Source form of any Derivative Works that You distribute,
95
+ all copyright, patent, trademark, and attribution notices from the Source form
96
+ of the Work, excluding those notices that do not pertain to any part of the
97
+ Derivative Works; and
98
+ If the Work includes a "NOTICE" text file as part of its distribution, then any
99
+ Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of the
102
+ following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents of
106
+ the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions.
118
+
119
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
120
+ for inclusion in the Work by You to the Licensor shall be under the terms and
121
+ conditions of this License, without any additional terms or conditions.
122
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
123
+ any separate license agreement you may have executed with Licensor regarding
124
+ such Contributions.
125
+
126
+ 6. Trademarks.
127
+
128
+ This License does not grant permission to use the trade names, trademarks,
129
+ service marks, or product names of the Licensor, except as required for
130
+ reasonable and customary use in describing the origin of the Work and
131
+ reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty.
134
+
135
+ Unless required by applicable law or agreed to in writing, Licensor provides the
136
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138
+ including, without limitation, any warranties or conditions of TITLE,
139
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140
+ solely responsible for determining the appropriateness of using or
141
+ redistributing the Work and assume any risks associated with Your exercise of
142
+ permissions under this License.
143
+
144
+ 8. Limitation of Liability.
145
+
146
+ In no event and under no legal theory, whether in tort (including negligence),
147
+ contract, or otherwise, unless required by applicable law (such as deliberate
148
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special, incidental,
150
+ or consequential damages of any character arising as a result of this License or
151
+ out of the use or inability to use the Work (including but not limited to
152
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153
+ any and all other commercial damages or losses), even if such Contributor has
154
+ been advised of the possibility of such damages.
155
+
156
+ 9. Accepting Warranty or Additional Liability.
157
+
158
+ While redistributing the Work or Derivative Works thereof, You may choose to
159
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160
+ other liability obligations and/or rights consistent with this License. However,
161
+ in accepting such obligations, You may act only on Your own behalf and on Your
162
+ sole responsibility, not on behalf of any other Contributor, and only if You
163
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
164
+ incurred by, or claims asserted against, such Contributor by reason of your
165
+ accepting any such warranty or additional liability.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+ APPENDIX: How to apply the Apache License to your work
170
+
171
+ To apply the Apache License to your work, attach the following boilerplate
172
+ notice, with the fields enclosed by brackets "[]" replaced with your own
173
+ identifying information. (Don't include the brackets!) The text should be
174
+ enclosed in the appropriate comment syntax for the file format. We also
175
+ recommend that a file or class name and description of purpose be included on
176
+ the same "printed page" as the copyright notice for easier identification within
177
+ third-party archives.
178
+
179
+ Copyright [yyyy] [name of copyright owner]
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,171 @@
1
+ fluent-plugin-glusterfs
2
+ =======================
3
+
4
+ fluentd Input plugin for GlusterFS logs.
5
+
6
+ ## Installation
7
+
8
+ ### for fluentd
9
+
10
+ `````
11
+ gem install fluent-plugin-glusterfs
12
+ `````
13
+
14
+ ### for td-agent
15
+
16
+ `````
17
+ /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-glusterfs
18
+ `````
19
+
20
+ ## Configuration
21
+
22
+ ### Log Level
23
+
24
+ You can specify the log level you want to output with fluentd/td-agent.
25
+ Originally it is set like following:
26
+
27
+ `````ruby
28
+ config_param :log_level, :string, :default => 'TDINWECA'
29
+ `````
30
+
31
+ For example you can set like following if you want it to send above warning level.
32
+
33
+ `````ruby
34
+ config_param :log_level, :string, :default => 'WECA'
35
+ `````
36
+
37
+ ### Handling parse failure
38
+
39
+ Of course it can parse almost of major GlusterFS logs. But GlusterFS has too many logs to test. So this plugin is designed to be able to handle parse failures. Given failed to parse a line, it set whole line into message field and set component name field as fluent-plugin-glusterfs.
40
+ This configuration is written as following:
41
+
42
+ `````ruby
43
+ @handle_parse_failure ||= true
44
+ `````
45
+
46
+ You can disable it in following way:
47
+
48
+ `````ruby
49
+ @handle_parse_failure = false
50
+ @handle_parse_failure ||= true
51
+ `````
52
+
53
+ ### Field names
54
+
55
+ You can modify the field names of JSON event log as you like.
56
+ The default setting is following:
57
+
58
+ `````ruby
59
+ field ||= {
60
+ :date => 'date',
61
+ :time => 'time',
62
+ :time_usec => 'time_usec',
63
+ :log_level => 'log_level',
64
+ :source_file_name => 'source_file_name',
65
+ :source_line => 'source_line',
66
+ :function_name => 'function_name',
67
+ :component_name => 'component_name',
68
+ :message => 'message',
69
+ :hostname => 'hostname'
70
+ }
71
+ `````
72
+
73
+ You might prefer another field name set so you can overwrite them like following:
74
+ `````ruby
75
+ field = {
76
+ :date => 'date',
77
+ :time => 'time',
78
+ :time_usec => 'usec',
79
+ :log_level => 'level',
80
+ :source_file_name => 'source',
81
+ :source_line => 'line',
82
+ :function_name => 'function',
83
+ :component_name => 'component',
84
+ :message => 'msg',
85
+ :hostname => 'peer'
86
+ }
87
+ field ||= {
88
+ :date => 'date',
89
+ :time => 'time',
90
+ :time_usec => 'time_usec',
91
+ :log_level => 'log_level',
92
+ :source_file_name => 'source_file_name',
93
+ :source_line => 'source_line',
94
+ :function_name => 'function_name',
95
+ :component_name => 'component_name',
96
+ :message => 'message',
97
+ :hostname => 'hostname'
98
+ }
99
+ `````
100
+
101
+ ### Hostname
102
+
103
+ It outputs the hostname of the node into each JSON log.
104
+ But you might specify your customized name as the hostname, then you can overwrite the following part:
105
+
106
+ `````ruby
107
+ @hostname ||= Socket.gethostname
108
+ `````
109
+
110
+ Just do it like following:
111
+
112
+ `````ruby
113
+ @hostname = example.com
114
+ @hostname ||= Socket.gethostname
115
+ `````
116
+
117
+ ## Usage
118
+
119
+ ### on GlusterFS nodes
120
+
121
+ `````
122
+ <source>
123
+ type glusterfs_log
124
+ path /var/log/glusterfs/usr-local-glusterfs-etc-glusterfs-glusterd.vol.log
125
+ pos_file /var/log/td-agent/usr-local-glusterfs-etc-glusterfs-glusterd.vol.log.pos
126
+ tag glusterfs_log.glusterd
127
+ format /^(?<message>.*)$/
128
+ refresh_interval 1800
129
+ </source>
130
+
131
+ <match glusterfs_log.**>
132
+ type forward
133
+ send_timeout 60s
134
+ recover_wait 10s
135
+ heartbeat_interval 1s
136
+ phi_threshold 8
137
+ hard_timeout 60s
138
+
139
+ <server>
140
+ name dev-centos
141
+ host 192.168.0.3
142
+ port 24224
143
+ weight 60
144
+ </server>
145
+
146
+ <secondary>
147
+ type file
148
+ path /var/log/td-agent/forward-failed
149
+ </secondary>
150
+ </match>
151
+ `````
152
+
153
+ ### on a log server
154
+
155
+ `````
156
+ <source>
157
+ type forward
158
+ port 24224
159
+ bind 0.0.0.0
160
+ </source>
161
+
162
+ <match glusterfs_log.glusterd>
163
+ type file
164
+ path /var/log/td-agent/glusterd
165
+ </match>
166
+ `````
167
+
168
+
169
+ ## License
170
+
171
+ Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new(:test) do |test|
6
+ test.libs << 'lib' << 'test'
7
+ test.test_files = FileList['test/**/test_*.rb']
8
+ test.verbose = true
9
+ end
10
+
11
+ task :default => :test
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "fluent-plugin-glusterfs"
6
+ gem.authors = ["Keisuke Takahashi"]
7
+ gem.email = ["keithseahus@gmail.com"]
8
+ gem.description = %q{Fluentd plugin for GlusterFS}
9
+ gem.summary = %q{Fluentd plugin for GlusterFS}
10
+ gem.homepage = "https://github.com/keithseahus/fluent-plugin-glusterfs"
11
+ gem.version = "1.0.0"
12
+
13
+ gem.files = `git ls-files`.split($\)
14
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
17
+
18
+ requires = ['fluentd']
19
+ requires.each {|name| gem.add_runtime_dependency name}
20
+ requires += ['rake']
21
+ requires.each {|name| gem.add_development_dependency name}
22
+ end
@@ -0,0 +1,119 @@
1
+ module Fluent
2
+ require 'fluent/plugin/in_tail'
3
+ require 'socket'
4
+
5
+ class GlusterfsLogInput < TailInput
6
+ Plugin.register_input("glusterfs_log", self)
7
+
8
+ # NOTE: Here you can specify log levels
9
+ # to retrieve in the log. (:default => 'TDINWECA')
10
+ config_param :log_level, :string, :default => 'TDINWECA'
11
+
12
+ def initialize
13
+ super
14
+
15
+ # NOTE: Here you can specify if output lines into the event stream
16
+ # that fluentd fails to parse or else. (:default => true)
17
+ @handle_parse_failure ||= true
18
+
19
+ # NOTE: Here you can configure field names of JSON.
20
+ # YOU SHOULD NOT SPECIFY EACH STRING AS NIL.
21
+ field ||= {
22
+ :date => 'date',
23
+ :time => 'time',
24
+ :time_usec => 'time_usec',
25
+ :log_level => 'log_level',
26
+ :source_file_name => 'source_file_name',
27
+ :source_line => 'source_line',
28
+ :function_name => 'function_name',
29
+ :component_name => 'component_name',
30
+ :message => 'message',
31
+ :hostname => 'hostname'
32
+ }
33
+
34
+ # NOTE: Here you can set an optional hostname in string which is
35
+ # output into the JSON event logs. (:default => Socket.gethostname)
36
+ @hostname ||= Socket.gethostname
37
+
38
+ # NOTE: NEVER MODIFY FOLLOWING INITIALIZATIONS.
39
+ @field = init_field(field)
40
+ @time_format = init_time_format
41
+ @regex = init_regex
42
+ end
43
+
44
+ def parse_line(line)
45
+ super
46
+
47
+ begin
48
+ return nil, nil unless line[0,1] == '['
49
+
50
+ time = 0
51
+ record = {}
52
+ if @regex =~ line
53
+ record = {
54
+ @field[:date] => $1,
55
+ @field[:time] => $2,
56
+ @field[:time_usec] => $3,
57
+ @field[:log_level] => $4,
58
+ @field[:source_file_name] => $5,
59
+ @field[:source_line] => $6,
60
+ @field[:function_name] => $7,
61
+ @field[:component_name] => $8,
62
+ @field[:message] => $9,
63
+ @field[:hostname] => @hostname
64
+ }
65
+ time = Time.strptime("#{record[@field[:date]]} #{record[@field[:time]]}", @time_format).to_i
66
+ elsif @handle_parse_failure
67
+ now = Time.now.utc
68
+ datetime = now.to_s.split(' ')
69
+ record = {
70
+ @field[:date] => datetime[0],
71
+ @field[:time] => datetime[1],
72
+ @field[:log_level] => 'I',
73
+ @field[:component_name] => 'fluent-plugin-glusterfs',
74
+ @field[:message] => "Could not parse the line : #{line}",
75
+ @field[:hostname] => @hostname
76
+ }
77
+ time = now.to_i
78
+ end
79
+
80
+ return time, record
81
+ rescue => ex
82
+ raise ex
83
+ end
84
+ end
85
+
86
+ private
87
+
88
+ def init_field(field)
89
+ f = {}
90
+ field.each do |k,v|
91
+ f[k] = v.to_sym unless k.empty?
92
+ end
93
+ return f
94
+ end
95
+
96
+ def init_time_format
97
+ '%Y-%m-%d %H:%M:%S'
98
+ end
99
+
100
+ def init_regex
101
+ @log_level = 'TDINWECA' unless @log_level
102
+ delimiter = '\[\]: '
103
+ re = {
104
+ :date => '\d{4}-[01]\d-[0-3]\d',
105
+ :time => '[0-2]\d\:[0-5]\d\:[0-6]\d',
106
+ :time_usec => '\d{6}',
107
+ :log_level => "[#{@log_level}]",
108
+ :source_file_name => "[^#{delimiter}]*",
109
+ :source_line => '\d*',
110
+ :function_name => "[^#{delimiter}]*",
111
+ :component_name => "[^:]*",
112
+ :message => '.*'
113
+ }
114
+
115
+ /\[(#{re[:date]}) (#{re[:time]}).(#{re[:time_usec]})\] (#{re[:log_level]}) \[(#{re[:source_file_name]}):(#{re[:source_line]}):(#{re[:function_name]})\] (#{re[:component_name]}): (#{re[:message]})/
116
+ end
117
+
118
+ end
119
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
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
+ require 'fluent/test'
15
+ unless ENV.has_key?('VERBOSE')
16
+ nulllogger = Object.new
17
+ nulllogger.instance_eval {|obj|
18
+ def method_missing(method, *args)
19
+ # pass
20
+ end
21
+ }
22
+ $log = nulllogger
23
+ end
24
+
25
+ require 'fluent/plugin/in_glusterfs_log'
26
+
27
+ class Test::Unit::TestCase
28
+ end
@@ -0,0 +1,483 @@
1
+ require 'helper'
2
+ require 'socket'
3
+
4
+ class GlusterfsLogInputTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ Fluent::Test.setup
8
+ FileUtils.rm_rf(TMP_DIR)
9
+ FileUtils.mkdir_p(TMP_DIR)
10
+ @hostname = Socket.gethostname
11
+ @time_format = '%Y-%m-%dT%H:%M:%S'
12
+ end
13
+
14
+ TMP_DIR = File.dirname(__FILE__) + '/../tmp'
15
+
16
+ log_file_path = 'test/plugin/data/log'
17
+ test_log_file_path = "#{log_file_path}/test_in_glusterfs/%Y%m%d-%H%M%S.log"
18
+ glusterfs_log_file_path = "#{log_file_path}/glusterfs/**/**/*.log"
19
+ config_format = '/^(?<message>.*)$/'
20
+ CONFIG = %[
21
+ tag glusterfs_log.glusterd
22
+ path #{test_log_file_path},#{glusterfs_log_file_path}
23
+ format #{config_format}
24
+ pos_file #{TMP_DIR}/etc-glusterfs-glusterd.vol.log.pos
25
+ refresh_interval 1800
26
+ rotate_wait 2s
27
+ ]
28
+
29
+ def create_driver(conf=CONFIG)
30
+ Fluent::Test::InputTestDriver.new(Fluent::GlusterfsLogInput).configure(conf)
31
+ end
32
+
33
+ def test_parse_line_client_glusterd_w_readv_failed
34
+ line = '[2013-07-15 13:45:05.309889] W [socket.c:514:__socket_rwv] 0-management: readv failed (No data available)'
35
+ time = Time.strptime("2013-07-15T13:45:05+9:00", @time_format).to_i
36
+ record = {
37
+ :date => '2013-07-15',
38
+ :time => '13:45:05',
39
+ :time_usec => '309889',
40
+ :log_level => 'W',
41
+ :source_file_name => 'socket.c',
42
+ :source_line => '514',
43
+ :function_name => '__socket_rwv',
44
+ :component_name => '0-management',
45
+ :message => 'readv failed (No data available)',
46
+ :hostname => @hostname
47
+ }
48
+ assert_equal [time, record], create_driver.instance.parse_line(line)
49
+ end
50
+
51
+ def test_parse_line_client_glusterd_w_reading_from_socket_failed
52
+ line = '[2013-07-15 13:45:05.309954] W [socket.c:1962:__socket_proto_state_machine] 0-management: reading from socket failed. Error (No data available), peer (192.168.0.12:24007)'
53
+ time = Time.strptime("2013-07-15T13:45:05", @time_format).to_i
54
+ record = {
55
+ :date => '2013-07-15',
56
+ :time => '13:45:05',
57
+ :time_usec => '309954',
58
+ :log_level => 'W',
59
+ :source_file_name => 'socket.c',
60
+ :source_line => '1962',
61
+ :function_name => '__socket_proto_state_machine',
62
+ :component_name => '0-management',
63
+ :message => 'reading from socket failed. Error (No data available), peer (192.168.0.12:24007)',
64
+ :hostname => @hostname
65
+ }
66
+ assert_equal [time, record], create_driver.instance.parse_line(line)
67
+ end
68
+
69
+ def test_parse_line_client_glusterd_e_connection_refused
70
+ line = '[2013-07-15 13:45:07.090755] E [socket.c:2157:socket_connect_finish] 0-management: connection to 192.168.0.12:24007 failed (Connection refused)'
71
+ time = Time.strptime("2013-07-15T13:45:07", @time_format).to_i
72
+ record = {
73
+ :date => '2013-07-15',
74
+ :time => '13:45:07',
75
+ :time_usec => '090755',
76
+ :log_level => 'E',
77
+ :source_file_name => 'socket.c',
78
+ :source_line => '2157',
79
+ :function_name => 'socket_connect_finish',
80
+ :component_name => '0-management',
81
+ :message => 'connection to 192.168.0.12:24007 failed (Connection refused)',
82
+ :hostname => @hostname
83
+ }
84
+ assert_equal [time, record], create_driver.instance.parse_line(line)
85
+ end
86
+
87
+ def test_parse_line_client_glusterd_i_received_friend_update
88
+ line = '[2013-07-15 13:45:32.902716] I [glusterd-handler.c:2020:__glusterd_handle_friend_update] 0-glusterd: Received friend update from uuid: 9d07f8cc-b0a1-417c-a132-4b3310f98945'
89
+ time = Time.strptime("2013-07-15T13:45:32", @time_format).to_i
90
+ record = {
91
+ :date => '2013-07-15',
92
+ :time => '13:45:32',
93
+ :time_usec => '902716',
94
+ :log_level => 'I',
95
+ :source_file_name => 'glusterd-handler.c',
96
+ :source_line => '2020',
97
+ :function_name => '__glusterd_handle_friend_update',
98
+ :component_name => '0-glusterd',
99
+ :message => 'Received friend update from uuid: 9d07f8cc-b0a1-417c-a132-4b3310f98945',
100
+ :hostname => @hostname
101
+ }
102
+ assert_equal [time, record], create_driver.instance.parse_line(line)
103
+ end
104
+
105
+ def test_parse_line_client_glusterd_i_de_registered_nfsv3_successfully
106
+ line = '[2013-07-15 13:46:08.751129] I [glusterd-utils.c:3627:glusterd_nfs_pmap_deregister] 0-: De-registered NFSV3 successfully'
107
+ time = Time.strptime("2013-07-15T13:46:08", @time_format).to_i
108
+ record = {
109
+ :date => '2013-07-15',
110
+ :time => '13:46:08',
111
+ :time_usec => '751129',
112
+ :log_level => 'I',
113
+ :source_file_name => 'glusterd-utils.c',
114
+ :source_line => '3627',
115
+ :function_name => 'glusterd_nfs_pmap_deregister',
116
+ :component_name => '0-',
117
+ :message => 'De-registered NFSV3 successfully',
118
+ :hostname => @hostname
119
+ }
120
+ assert_equal [time, record], create_driver.instance.parse_line(line)
121
+ end
122
+
123
+ def test_parse_line_client_glusterd_e_failed_to_remove_socket
124
+ line = '[2013-07-15 13:46:09.753811] E [glusterd-utils.c:3583:glusterd_nodesvc_unlink_socket_file] 0-management: Failed to remove /var/run/9603d75b8cac40f80e82ca4f161672b9.socket error: No such file or director'
125
+ time = Time.strptime("2013-07-15T13:46:09", @time_format).to_i
126
+ record = {
127
+ :date => '2013-07-15',
128
+ :time => '13:46:09',
129
+ :time_usec => '753811',
130
+ :log_level => 'E',
131
+ :source_file_name => 'glusterd-utils.c',
132
+ :source_line => '3583',
133
+ :function_name => 'glusterd_nodesvc_unlink_socket_file',
134
+ :component_name => '0-management',
135
+ :message => 'Failed to remove /var/run/9603d75b8cac40f80e82ca4f161672b9.socket error: No such file or director',
136
+ :hostname => @hostname
137
+ }
138
+ assert_equal [time, record], create_driver.instance.parse_line(line)
139
+ end
140
+
141
+ def test_parse_line_client_nfs_i_started_running
142
+ line = '[2013-07-15 13:42:34.485000] I [glusterfsd.c:1878:main] 0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs: Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs -s localhost --volfile-id gluster/nfs -p /var/lib/glusterd/nfs/run/nfs.pid -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/nfs.log -S /var/run/e771e6272849a2f9b9b77d1cba799ae9.socket)'
143
+ time = Time.strptime("2013-07-15T13:42:34", @time_format).to_i
144
+ record = {
145
+ :date => '2013-07-15',
146
+ :time => '13:42:34',
147
+ :time_usec => '485000',
148
+ :log_level => 'I',
149
+ :source_file_name => 'glusterfsd.c',
150
+ :source_line => '1878',
151
+ :function_name => 'main',
152
+ :component_name => '0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs',
153
+ :message => 'Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs -s localhost --volfile-id gluster/nfs -p /var/lib/glusterd/nfs/run/nfs.pid -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/nfs.log -S /var/run/e771e6272849a2f9b9b77d1cba799ae9.socket)',
154
+ :hostname => @hostname
155
+ }
156
+ assert_equal [time, record], create_driver.instance.parse_line(line)
157
+ end
158
+
159
+ def test_parse_line_client_nfs_w_readv_failed
160
+ line = '[2013-07-15 13:42:34.742845] W [socket.c:514:__socket_rwv] 0-fluent-plugin-test-client-0: readv failed (No data available)'
161
+ time = Time.strptime("2013-07-15T13:42:34", @time_format).to_i
162
+ record = {
163
+ :date => '2013-07-15',
164
+ :time => '13:42:34',
165
+ :time_usec => '742845',
166
+ :log_level => 'W',
167
+ :source_file_name => 'socket.c',
168
+ :source_line => '514',
169
+ :function_name => '__socket_rwv',
170
+ :component_name => '0-fluent-plugin-test-client-0',
171
+ :message => 'readv failed (No data available)',
172
+ :hostname => @hostname
173
+ }
174
+ assert_equal [time, record], create_driver.instance.parse_line(line)
175
+ end
176
+
177
+ def test_parse_line_client_mnt_i_started_running
178
+ line = '[2013-07-15 13:44:04.812937] I [glusterfsd.c:1878:main] 0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs: Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs --volfile-id=fluent-plugin-test --volfile-server=localhost /mnt/glusterfs/fluent-plugin-test)'
179
+ time = Time.strptime("2013-07-15T13:44:04", @time_format).to_i
180
+ record = {
181
+ :date => '2013-07-15',
182
+ :time => '13:44:04',
183
+ :time_usec => '812937',
184
+ :log_level => 'I',
185
+ :source_file_name => 'glusterfsd.c',
186
+ :source_line => '1878',
187
+ :function_name => 'main',
188
+ :component_name => '0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs',
189
+ :message => 'Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs --volfile-id=fluent-plugin-test --volfile-server=localhost /mnt/glusterfs/fluent-plugin-test)',
190
+ :hostname => @hostname
191
+ }
192
+ assert_equal [time, record], create_driver.instance.parse_line(line)
193
+ end
194
+
195
+ def test_parse_line_client_mnt_w_shutting_down
196
+ line = '[2013-07-15 13:45:50.657199] W [glusterfsd.c:970:cleanup_and_exit] (-->/lib64/libc.so.6(clone+0x6d) [0x7fe6d511790d] (-->/lib64/libpthread.so.0(+0x7851) [0x7fe6d5763851] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs(glusterfs_sigwaiter+0xe4) [0x407b7b]))) 0-: received signum (15), shutting down'
197
+ time = Time.strptime("2013-07-15T13:45:50", @time_format).to_i
198
+ record = {
199
+ :date => '2013-07-15',
200
+ :time => '13:45:50',
201
+ :time_usec => '657199',
202
+ :log_level => 'W',
203
+ :source_file_name => 'glusterfsd.c',
204
+ :source_line => '970',
205
+ :function_name => 'cleanup_and_exit',
206
+ :component_name => '(-->/lib64/libc.so.6(clone+0x6d) [0x7fe6d511790d] (-->/lib64/libpthread.so.0(+0x7851) [0x7fe6d5763851] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs(glusterfs_sigwaiter+0xe4) [0x407b7b]))) 0-',
207
+ :message => 'received signum (15), shutting down',
208
+ :hostname => @hostname
209
+ }
210
+ assert_equal [time, record], create_driver.instance.parse_line(line)
211
+ end
212
+
213
+ def test_parse_line_client_glustershd_i_started_running
214
+ line = '[2013-07-15 13:42:34.498071] I [glusterfsd.c:1878:main] 0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs: Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs -s localhost --volfile-id gluster/glustershd -p /var/lib/glusterd/glustershd/run/glustershd.pid -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/glustershd.log -S /var/run/9603d75b8cac40f80e82ca4f161672b9.socket --xlator-option *replicate*.node-uuid=000fcaf8-f160-4933-ad79-f02b309c3000)'
215
+ time = Time.strptime("2013-07-15T13:42:34", @time_format).to_i
216
+ record = {
217
+ :date => '2013-07-15',
218
+ :time => '13:42:34',
219
+ :time_usec => '498071',
220
+ :log_level => 'I',
221
+ :source_file_name => 'glusterfsd.c',
222
+ :source_line => '1878',
223
+ :function_name => 'main',
224
+ :component_name => '0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs',
225
+ :message => 'Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs -s localhost --volfile-id gluster/glustershd -p /var/lib/glusterd/glustershd/run/glustershd.pid -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/glustershd.log -S /var/run/9603d75b8cac40f80e82ca4f161672b9.socket --xlator-option *replicate*.node-uuid=000fcaf8-f160-4933-ad79-f02b309c3000)',
226
+ :hostname => @hostname
227
+ }
228
+ assert_equal [time, record], create_driver.instance.parse_line(line)
229
+ end
230
+
231
+ def test_parse_line_client_glustershd_w_shutting_down
232
+ line = '[2013-07-15 13:46:08.751690] W [glusterfsd.c:970:cleanup_and_exit] (-->/lib64/libc.so.6(clone+0x6d) [0x7f3bad27090d] (-->/lib64/libpthread.so.0(+0x7851) [0x7f3bad8bc851] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs(glusterfs_sigwaiter+0xe4) [0x407b7b]))) 0-: received signum (15), shutting down'
233
+ time = Time.strptime("2013-07-15T13:46:08", @time_format).to_i
234
+ record = {
235
+ :date => '2013-07-15',
236
+ :time => '13:46:08',
237
+ :time_usec => '751690',
238
+ :log_level => 'W',
239
+ :source_file_name => 'glusterfsd.c',
240
+ :source_line => '970',
241
+ :function_name => 'cleanup_and_exit',
242
+ :component_name => '(-->/lib64/libc.so.6(clone+0x6d) [0x7f3bad27090d] (-->/lib64/libpthread.so.0(+0x7851) [0x7f3bad8bc851] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs(glusterfs_sigwaiter+0xe4) [0x407b7b]))) 0-',
243
+ :message => 'received signum (15), shutting down',
244
+ :hostname => @hostname
245
+ }
246
+ assert_equal [time, record], create_driver.instance.parse_line(line)
247
+ end
248
+
249
+ def test_parse_line_client_cli_i_create_volume
250
+ line = '[2013-07-15 13:41:22.447332] I [cli-rpc-ops.c:798:gf_cli_create_volume_cbk] 0-cli: Received resp to create volume'
251
+ time = Time.strptime("2013-07-15T13:41:22", @time_format).to_i
252
+ record = {
253
+ :date => '2013-07-15',
254
+ :time => '13:41:22',
255
+ :time_usec => '447332',
256
+ :log_level => 'I',
257
+ :source_file_name => 'cli-rpc-ops.c',
258
+ :source_line => '798',
259
+ :function_name => 'gf_cli_create_volume_cbk',
260
+ :component_name => '0-cli',
261
+ :message => 'Received resp to create volume',
262
+ :hostname => @hostname
263
+ }
264
+ assert_equal [time, record], create_driver.instance.parse_line(line)
265
+ end
266
+
267
+ def test_parse_line_client_cli_i_start_volume
268
+ line = '[2013-07-15 13:42:34.606620] I [cli-rpc-ops.c:1011:gf_cli_start_volume_cbk] 0-cli: Received resp to start volume'
269
+ time = Time.strptime("2013-07-15T13:42:34", @time_format).to_i
270
+ record = {
271
+ :date => '2013-07-15',
272
+ :time => '13:42:34',
273
+ :time_usec => '606620',
274
+ :log_level => 'I',
275
+ :source_file_name => 'cli-rpc-ops.c',
276
+ :source_line => '1011',
277
+ :function_name => 'gf_cli_start_volume_cbk',
278
+ :component_name => '0-cli',
279
+ :message => 'Received resp to start volume',
280
+ :hostname => @hostname
281
+ }
282
+ assert_equal [time, record], create_driver.instance.parse_line(line)
283
+ end
284
+
285
+ def test_parse_line_client_cli_i_stop_volume
286
+ line = '[2013-07-15 13:46:11.781550] I [cli-rpc-ops.c:1089:gf_cli_stop_volume_cbk] 0-cli: Received resp to stop volume'
287
+ time = Time.strptime("2013-07-15T13:46:11", @time_format).to_i
288
+ record = {
289
+ :date => '2013-07-15',
290
+ :time => '13:46:11',
291
+ :time_usec => '781550',
292
+ :log_level => 'I',
293
+ :source_file_name => 'cli-rpc-ops.c',
294
+ :source_line => '1089',
295
+ :function_name => 'gf_cli_stop_volume_cbk',
296
+ :component_name => '0-cli',
297
+ :message => 'Received resp to stop volume',
298
+ :hostname => @hostname
299
+ }
300
+ assert_equal [time, record], create_driver.instance.parse_line(line)
301
+ end
302
+
303
+ def test_parse_line_server_glusterd_w_reading_from_socket_failed
304
+ line = '[2013-07-15 13:45:21.758927] W [socket.c:1962:__socket_proto_state_machine] 0-management: reading from socket failed. Error (No data available), peer (192.168.0.12:24007)'
305
+ time = Time.strptime("2013-07-15T13:45:21", @time_format).to_i
306
+ record = {
307
+ :date => '2013-07-15',
308
+ :time => '13:45:21',
309
+ :time_usec => '758927',
310
+ :log_level => 'W',
311
+ :source_file_name => 'socket.c',
312
+ :source_line => '1962',
313
+ :function_name => '__socket_proto_state_machine',
314
+ :component_name => '0-management',
315
+ :message => 'reading from socket failed. Error (No data available), peer (192.168.0.12:24007)',
316
+ :hostname => @hostname
317
+ }
318
+ assert_equal [time, record], create_driver.instance.parse_line(line)
319
+ end
320
+
321
+ def test_parse_line_server_glusterd_e_connection_failed
322
+ line = '[2013-07-15 13:45:24.637443] E [socket.c:2157:socket_connect_finish] 0-management: connection to 192.168.0.12:24007 failed (Connection refused)'
323
+ time = Time.strptime("2013-07-15T13:45:24", @time_format).to_i
324
+ record = {
325
+ :date => '2013-07-15',
326
+ :time => '13:45:24',
327
+ :time_usec => '637443',
328
+ :log_level => 'E',
329
+ :source_file_name => 'socket.c',
330
+ :source_line => '2157',
331
+ :function_name => 'socket_connect_finish',
332
+ :component_name => '0-management',
333
+ :message => 'connection to 192.168.0.12:24007 failed (Connection refused)',
334
+ :hostname => @hostname
335
+ }
336
+ assert_equal [time, record], create_driver.instance.parse_line(line)
337
+ end
338
+
339
+ def test_parse_line_server_glusterd_e_unable_to_open_pidfile
340
+ line = '[2013-07-15 13:46:26.209153] E [glusterd-utils.c:1082:glusterd_service_stop] 0-management: Unable to open pidfile: /var/lib/glusterd/vols/fluent-plugin-test/run/glusterfs-unstable-01-mnt-lv0-fluent-plugin-test.pid'
341
+ time = Time.strptime("2013-07-15T13:46:26", @time_format).to_i
342
+ record = {
343
+ :date => '2013-07-15',
344
+ :time => '13:46:26',
345
+ :time_usec => '209153',
346
+ :log_level => 'E',
347
+ :source_file_name => 'glusterd-utils.c',
348
+ :source_line => '1082',
349
+ :function_name => 'glusterd_service_stop',
350
+ :component_name => '0-management',
351
+ :message => 'Unable to open pidfile: /var/lib/glusterd/vols/fluent-plugin-test/run/glusterfs-unstable-01-mnt-lv0-fluent-plugin-test.pid',
352
+ :hostname => @hostname
353
+ }
354
+ assert_equal [time, record], create_driver.instance.parse_line(line)
355
+ end
356
+
357
+ def test_parse_line_server_glusterd_e_failed_to_remove_socket
358
+ line = '[2013-07-15 13:46:26.209800] E [glusterd-utils.c:1455:glusterd_brick_unlink_socket_file] 0-management: Failed to remove /var/run/5bfeb92485191dab05ce086134861afd.socket error: No such file or directory'
359
+ time = Time.strptime("2013-07-15T13:46:26", @time_format).to_i
360
+ record = {
361
+ :date => '2013-07-15',
362
+ :time => '13:46:26',
363
+ :time_usec => '209800',
364
+ :log_level => 'E',
365
+ :source_file_name => 'glusterd-utils.c',
366
+ :source_line => '1455',
367
+ :function_name => 'glusterd_brick_unlink_socket_file',
368
+ :component_name => '0-management',
369
+ :message => 'Failed to remove /var/run/5bfeb92485191dab05ce086134861afd.socket error: No such file or directory',
370
+ :hostname => @hostname
371
+ }
372
+ assert_equal [time, record], create_driver.instance.parse_line(line)
373
+ end
374
+
375
+ def test_parse_line_server_glusterd_i_removing_brick
376
+ line = '[2013-07-15 13:46:28.231270] I [glusterd-pmap.c:271:pmap_registry_remove] 0-pmap: removing brick /mnt/lv0/fluent-plugin-test on port 49155'
377
+ time = Time.strptime("2013-07-15T13:46:28", @time_format).to_i
378
+ record = {
379
+ :date => '2013-07-15',
380
+ :time => '13:46:28',
381
+ :time_usec => '231270',
382
+ :log_level => 'I',
383
+ :source_file_name => 'glusterd-pmap.c',
384
+ :source_line => '271',
385
+ :function_name => 'pmap_registry_remove',
386
+ :component_name => '0-pmap',
387
+ :message => 'removing brick /mnt/lv0/fluent-plugin-test on port 49155',
388
+ :hostname => @hostname
389
+ }
390
+ assert_equal [time, record], create_driver.instance.parse_line(line)
391
+ end
392
+
393
+ def test_parse_line_server_glustershd_i_started_running
394
+ line = '[2013-07-15 13:42:51.088334] I [glusterfsd.c:1878:main] 0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs: Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs -s localhost --volfile-id gluster/glustershd -p /var/lib/glusterd/glustershd/run/glustershd.pid -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/glustershd.log -S /var/run/08d90b8cacfaaf498f725ad25fa58da0.socket --xlator-option *replicate*.node-uuid=9d07f8cc-b0a1-417c-a132-4b3310f98945)'
395
+ time = Time.strptime("2013-07-15T13:42:51", @time_format).to_i
396
+ record = {
397
+ :date => '2013-07-15',
398
+ :time => '13:42:51',
399
+ :time_usec => '088334',
400
+ :log_level => 'I',
401
+ :source_file_name => 'glusterfsd.c',
402
+ :source_line => '1878',
403
+ :function_name => 'main',
404
+ :component_name => '0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs',
405
+ :message => 'Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfs version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs -s localhost --volfile-id gluster/glustershd -p /var/lib/glusterd/glustershd/run/glustershd.pid -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/glustershd.log -S /var/run/08d90b8cacfaaf498f725ad25fa58da0.socket --xlator-option *replicate*.node-uuid=9d07f8cc-b0a1-417c-a132-4b3310f98945)',
406
+ :hostname => @hostname
407
+ }
408
+ assert_equal [time, record], create_driver.instance.parse_line(line)
409
+ end
410
+
411
+ def test_parse_line_server_glustershd_e_all_subvolumes_are_down
412
+ line = '[2013-07-15 13:46:26.213025] E [afr-common.c:3735:afr_notify] 0-fluent-plugin-test-replicate-0: All subvolumes are down. Going offline until atleast one of them comes back up.'
413
+ time = Time.strptime("2013-07-15T13:46:26", @time_format).to_i
414
+ record = {
415
+ :date => '2013-07-15',
416
+ :time => '13:46:26',
417
+ :time_usec => '213025',
418
+ :log_level => 'E',
419
+ :source_file_name => 'afr-common.c',
420
+ :source_line => '3735',
421
+ :function_name => 'afr_notify',
422
+ :component_name => '0-fluent-plugin-test-replicate-0',
423
+ :message => 'All subvolumes are down. Going offline until atleast one of them comes back up.',
424
+ :hostname => @hostname
425
+ }
426
+ assert_equal [time, record], create_driver.instance.parse_line(line)
427
+ end
428
+
429
+ def test_parse_line_server_glustershd_w_shutting_down
430
+ line = '[2013-07-15 13:46:27.227274] W [glusterfsd.c:970:cleanup_and_exit] (-->/lib64/libc.so.6(clone+0x6d) [0x7f67143bf90d] (-->/lib64/libpthread.so.0(+0x7851) [0x7f6714a0b851] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs(glusterfs_sigwaiter+0xe4) [0x407b7b]))) 0-: received signum (15), shutting down'
431
+ time = Time.strptime("2013-07-15T13:46:27", @time_format).to_i
432
+ record = {
433
+ :date => '2013-07-15',
434
+ :time => '13:46:27',
435
+ :time_usec => '227274',
436
+ :log_level => 'W',
437
+ :source_file_name => 'glusterfsd.c',
438
+ :source_line => '970',
439
+ :function_name => 'cleanup_and_exit',
440
+ :component_name => '(-->/lib64/libc.so.6(clone+0x6d) [0x7f67143bf90d] (-->/lib64/libpthread.so.0(+0x7851) [0x7f6714a0b851] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfs(glusterfs_sigwaiter+0xe4) [0x407b7b]))) 0-',
441
+ :message => 'received signum (15), shutting down',
442
+ :hostname => @hostname
443
+ }
444
+ assert_equal [time, record], create_driver.instance.parse_line(line)
445
+ end
446
+
447
+ def test_parse_line_server_brick_i_started_running
448
+ line = '[2013-07-15 13:42:50.952881] I [glusterfsd.c:1878:main] 0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd: Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd -s glusterfs-unstable-01 --volfile-id fluent-plugin-test.glusterfs-unstable-01.mnt-lv0-fluent-plugin-test -p /var/lib/glusterd/vols/fluent-plugin-test/run/glusterfs-unstable-01-mnt-lv0-fluent-plugin-test.pid -S /var/run/5bfeb92485191dab05ce086134861afd.socket --brick-name /mnt/lv0/fluent-plugin-test -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/bricks/mnt-lv0-fluent-plugin-test.log --xlator-option *-posix.glusterd-uuid=9d07f8cc-b0a1-417c-a132-4b3310f98945 --brick-port 49155 --xlator-option fluent-plugin-test-server.listen-port=49155)'
449
+ time = Time.strptime("2013-07-15T13:42:50", @time_format).to_i
450
+ record = {
451
+ :date => '2013-07-15',
452
+ :time => '13:42:50',
453
+ :time_usec => '952881',
454
+ :log_level => 'I',
455
+ :source_file_name => 'glusterfsd.c',
456
+ :source_line => '1878',
457
+ :function_name => 'main',
458
+ :component_name => '0-/usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd',
459
+ :message => 'Started running /usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd version 3.4.0beta2 (/usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd -s glusterfs-unstable-01 --volfile-id fluent-plugin-test.glusterfs-unstable-01.mnt-lv0-fluent-plugin-test -p /var/lib/glusterd/vols/fluent-plugin-test/run/glusterfs-unstable-01-mnt-lv0-fluent-plugin-test.pid -S /var/run/5bfeb92485191dab05ce086134861afd.socket --brick-name /mnt/lv0/fluent-plugin-test -l /usr/local/glusterfs-3.4.0beta2/var/log/glusterfs/bricks/mnt-lv0-fluent-plugin-test.log --xlator-option *-posix.glusterd-uuid=9d07f8cc-b0a1-417c-a132-4b3310f98945 --brick-port 49155 --xlator-option fluent-plugin-test-server.listen-port=49155)',
460
+ :hostname => @hostname
461
+ }
462
+ assert_equal [time, record], create_driver.instance.parse_line(line)
463
+ end
464
+
465
+ def test_parse_line_server_brick_w_shutting_down
466
+ line = '[2013-07-15 13:46:26.207044] W [glusterfsd.c:970:cleanup_and_exit] (-->/lib64/libc.so.6(+0x43b70) [0x7fe8eb17eb70] (-->/usr/local/glusterfs-3.4.0beta2/lib/libglusterfs.so.0(synctask_wrap+0x38) [0x7fe8ebf17909] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd(glusterfs_handle_terminate+0x27) [0x408c77]))) 0-: received signum (15), shutting down'
467
+ time = Time.strptime("2013-07-15T13:46:26", @time_format).to_i
468
+ record = {
469
+ :date => '2013-07-15',
470
+ :time => '13:46:26',
471
+ :time_usec => '207044',
472
+ :log_level => 'W',
473
+ :source_file_name => 'glusterfsd.c',
474
+ :source_line => '970',
475
+ :function_name => 'cleanup_and_exit',
476
+ :component_name => '(-->/lib64/libc.so.6(+0x43b70) [0x7fe8eb17eb70] (-->/usr/local/glusterfs-3.4.0beta2/lib/libglusterfs.so.0(synctask_wrap+0x38) [0x7fe8ebf17909] (-->/usr/local/glusterfs-3.4.0beta2/sbin/glusterfsd(glusterfs_handle_terminate+0x27) [0x408c77]))) 0-',
477
+ :message => 'received signum (15), shutting down',
478
+ :hostname => @hostname
479
+ }
480
+ assert_equal [time, record], create_driver.instance.parse_line(line)
481
+ end
482
+
483
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-glusterfs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Keisuke Takahashi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fluentd
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: fluentd
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Fluentd plugin for GlusterFS
63
+ email:
64
+ - keithseahus@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE
72
+ - README.md
73
+ - Rakefile
74
+ - fluent-plugin-glusterfs.gemspec
75
+ - lib/fluent/plugin/in_glusterfs_log.rb
76
+ - test/helper.rb
77
+ - test/plugin/test_in_glusterfs_log.rb
78
+ homepage: https://github.com/keithseahus/fluent-plugin-glusterfs
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ segments:
91
+ - 0
92
+ hash: 2073878181694956015
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ segments:
100
+ - 0
101
+ hash: 2073878181694956015
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 1.8.25
105
+ signing_key:
106
+ specification_version: 3
107
+ summary: Fluentd plugin for GlusterFS
108
+ test_files:
109
+ - test/helper.rb
110
+ - test/plugin/test_in_glusterfs_log.rb