fluent-diagtool 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -15
- data/README.md +33 -9
- data/exe/fluent-diagtool +0 -3
- data/lib/fluent/diagtool/collectutils.rb +69 -9
- data/lib/fluent/diagtool/diagutils.rb +53 -8
- data/lib/fluent/diagtool/version.rb +1 -1
- data/lib/fluent/diagtool/windows/collectutils.rb +42 -0
- data/lib/fluent/diagtool/windows/diagutils.rb +101 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f767598bf5753ebc1ce4834843a5612d606b0d4d4ac5be26c6538d8d0f7db8fb
|
4
|
+
data.tar.gz: 93cef94976209e28812ab6ca5d466efcdc80c438222477e013d2bc365d8c8cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b45ed8576c82a0d7f772c516127ac66d03d0a2d1051cb34a663e2062c3fb2e27ad8160acba33bf9c7995485d403ae135fc496984a55b05a772d61273ce1aca0
|
7
|
+
data.tar.gz: 2af458d2e1202db45ebe0ddf6e6ab4e75dec2e9f53b995712ce20836a372af86588ddc5e7bb705c947a12c50673c35b8378f55ebb5c0615625c30f789112de95
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-diagtool (1.0.
|
4
|
+
fluent-diagtool (1.0.4)
|
5
5
|
fileutils
|
6
6
|
json
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
diff-lcs (1.
|
12
|
-
fileutils (1.
|
13
|
-
json (2.
|
11
|
+
diff-lcs (1.5.1)
|
12
|
+
fileutils (1.7.2)
|
13
|
+
json (2.7.1)
|
14
14
|
rake (12.3.3)
|
15
|
-
rspec (3.
|
16
|
-
rspec-core (~> 3.
|
17
|
-
rspec-expectations (~> 3.
|
18
|
-
rspec-mocks (~> 3.
|
19
|
-
rspec-core (3.
|
20
|
-
rspec-support (~> 3.
|
21
|
-
rspec-expectations (3.
|
15
|
+
rspec (3.13.0)
|
16
|
+
rspec-core (~> 3.13.0)
|
17
|
+
rspec-expectations (~> 3.13.0)
|
18
|
+
rspec-mocks (~> 3.13.0)
|
19
|
+
rspec-core (3.13.0)
|
20
|
+
rspec-support (~> 3.13.0)
|
21
|
+
rspec-expectations (3.13.0)
|
22
22
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-mocks (3.
|
23
|
+
rspec-support (~> 3.13.0)
|
24
|
+
rspec-mocks (3.13.0)
|
25
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-support (3.
|
26
|
+
rspec-support (~> 3.13.0)
|
27
|
+
rspec-support (3.13.1)
|
28
28
|
|
29
29
|
PLATFORMS
|
30
30
|
ruby
|
data/README.md
CHANGED
@@ -21,7 +21,8 @@ The scope of data collection:
|
|
21
21
|
<br>
|
22
22
|
|
23
23
|
## Prerequisite
|
24
|
-
Diagtool has been developed for Fluentd(td-agent) and FluentBit(td-agent-bit) running on Linux OS
|
24
|
+
Diagtool has been developed for Fluentd(td-agent, fluent-package) and FluentBit(td-agent-bit) running on Linux OS, mainly.
|
25
|
+
On Windows, it only supports the `installed td-agent-gem list` collection for Fluentd, currently (since v1.0.3).
|
25
26
|
Diagtool is written in Ruby and Ruby version should be higher than 2.3 for the installation.
|
26
27
|
The supported Linux OS is described in the following page:
|
27
28
|
https://docs.fluentd.org/quickstart/td-agent-v2-vs-v3-vs-v4
|
@@ -31,9 +32,9 @@ https://docs.fluentd.org/quickstart/td-agent-v2-vs-v3-vs-v4
|
|
31
32
|
When you are using td-agent, you can install Diagtool easily with "/usr/sbin/td-agent-gem" command.
|
32
33
|
```
|
33
34
|
# /usr/sbin/td-agent-gem install fluent-diagtool
|
34
|
-
Successfully installed fluent-diagtool-1.0.
|
35
|
-
Parsing documentation for fluent-diagtool-1.0.
|
36
|
-
Installing ri documentation for fluent-diagtool-1.0.
|
35
|
+
Successfully installed fluent-diagtool-1.0.4
|
36
|
+
Parsing documentation for fluent-diagtool-1.0.4
|
37
|
+
Installing ri documentation for fluent-diagtool-1.0.4
|
37
38
|
Done installing documentation for fluent-diagtool after 0 seconds
|
38
39
|
1 gem installed
|
39
40
|
```
|
@@ -42,9 +43,9 @@ When using /usr/sbin/td-agent-gem command, fluent-diagtool is installed under "/
|
|
42
43
|
Otherwise, you can install Diagtool with common gem command. In this case, Ruby version higher than 2.3 might be required to install.
|
43
44
|
```
|
44
45
|
# gem install fluent-diagtool
|
45
|
-
Successfully installed fluent-diagtool-1.0.
|
46
|
-
Parsing documentation for fluent-diagtool-1.0.
|
47
|
-
Installing ri documentation for fluent-diagtool-1.0.
|
46
|
+
Successfully installed fluent-diagtool-1.0.4
|
47
|
+
Parsing documentation for fluent-diagtool-1.0.4
|
48
|
+
Installing ri documentation for fluent-diagtool-1.0.4
|
48
49
|
Done installing documentation for fluent-diagtool after 0 seconds
|
49
50
|
1 gem installed
|
50
51
|
```
|
@@ -64,7 +65,13 @@ Usage: fluent-diagtool -o OUTPUT_DIR -m {yes | no} -w {word1,[word2...]} -f {lis
|
|
64
65
|
-c, --conf config_file provide a full path of td-agent configuration file (Optional : Default=None)
|
65
66
|
-l, --log log_file provide a full path of td-agent log file (Optional : Default=None)
|
66
67
|
```
|
68
|
+
|
69
|
+
On Windows, only the `-o, --output DIR` option is supported.
|
70
|
+
|
67
71
|
### Precheck
|
72
|
+
|
73
|
+
(Not supported on Windows)
|
74
|
+
|
68
75
|
In order to run Diagtool correctly, it is required to ensure that Diagtool can obtain the fundamental information of Fluentd. Basically, Diagtool automatically parses the required information from the running Fluentd processes. The precheck option is useful to confirm if Diagtool certainly collects the information as expected.
|
69
76
|
The following output example shows the case where Diatool properly collects the required information.
|
70
77
|
|
@@ -162,6 +169,21 @@ Once the pre-check is completed, you are ready to run the tool. The “-o” is
|
|
162
169
|
2020-10-07 21:29:30 +0000: [Diagtool] [INFO] [Collect] Generate tar file /tmp/diagout-20201007212928.tar.gz
|
163
170
|
```
|
164
171
|
|
172
|
+
fluent-package (td-agent) on Windows: Fluent Package Command Prompt (Td-agent Command Prompt) with Administrator privilege
|
173
|
+
|
174
|
+
```
|
175
|
+
$ fluent-diagtool -o /opt
|
176
|
+
2023-11-21 12:46:08 +0900: [Diagtool] [INFO] Parsing command options...
|
177
|
+
2023-11-21 12:46:08 +0900: [Diagtool] [INFO] Option : Output directory = /opt
|
178
|
+
2023-11-21 12:46:08 +0900: [Diagtool] [INFO] Initializing parameters...
|
179
|
+
2023-11-21 12:46:08 +0900: [Diagtool] [INFO] [Collect] Collecting fluent-package gem information...
|
180
|
+
2023-11-21 12:46:10 +0900: [Diagtool] [INFO] [Collect] fluent-package gem information is stored in /opt/20231121124608/output/tdgem_list.output
|
181
|
+
2023-11-21 12:46:10 +0900: [Diagtool] [INFO] [Collect] fluent-package gem information (bundled by default) is stored in /opt/20231121124608/output/gem_bundled_list.output
|
182
|
+
2023-11-21 12:46:10 +0900: [Diagtool] [INFO] [Collect] fluent-package manually installed gem information is stored in /opt/20231121124608/output/gem_local_list.output
|
183
|
+
2023-11-21 12:46:10 +0900: [Diagtool] [INFO] [Collect] fluent-package manually installed gems:
|
184
|
+
2023-11-21 12:46:10 +0900: [Diagtool] [INFO] [Collect] * fluent-plugin-forest
|
185
|
+
```
|
186
|
+
|
165
187
|
#### The "@include" directive in td-agent configuration file
|
166
188
|
The "@include" directive is a function to reuse configuration defined in other configuration files. Diagtool reads Fluentd configuration and gathers the files described in "@include" directive as well. The details of "@include" directive are described in followed page:
|
167
189
|
https://docs.fluentd.org/configuration/config-file#6-re-use-your-config-the-include-directive
|
@@ -203,6 +225,8 @@ The diagtool provides a hash-seed option with '-s'. When hash-seed is specified,
|
|
203
225
|
```
|
204
226
|
|
205
227
|
## Tested Environment
|
206
|
-
- OS : CentOS 8.1 / Ubuntu 20.04
|
228
|
+
- OS : CentOS 8.1 / Ubuntu 20.04 / Windows Home 10
|
207
229
|
- Fluentd : td-agent version 3/4
|
208
|
-
https://docs.fluentd.org/quickstart/td-agent-v2-vs-v3
|
230
|
+
https://docs.fluentd.org/quickstart/td-agent-v2-vs-v3-vs-v4
|
231
|
+
- Fluentd : fluent-package version 5
|
232
|
+
https://docs.fluentd.org/quickstart/fluent-package-v5-vs-td-agent
|
data/exe/fluent-diagtool
CHANGED
@@ -19,9 +19,12 @@ require 'open3'
|
|
19
19
|
require 'logger'
|
20
20
|
require 'net/http'
|
21
21
|
require 'uri'
|
22
|
+
require 'fluent/diagtool/windows/collectutils' if Diagtool.windows?
|
22
23
|
|
23
24
|
module Diagtool
|
24
25
|
class CollectUtils
|
26
|
+
prepend Windows::PlatformSpecificCollectUtils if Diagtool.windows?
|
27
|
+
|
25
28
|
def initialize(conf, log_level)
|
26
29
|
@logger = Logger.new(STDOUT, level: log_level, formatter: proc {|severity, datetime, progname, msg|
|
27
30
|
"#{datetime}: [Collectutils] [#{severity}] #{msg}\n"
|
@@ -34,8 +37,9 @@ module Diagtool
|
|
34
37
|
@outdir = conf[:outdir]
|
35
38
|
@tdenv = {
|
36
39
|
'FLUENT_CONF' => '',
|
37
|
-
'TD_AGENT_LOG_FILE' => ''
|
38
|
-
|
40
|
+
'TD_AGENT_LOG_FILE' => '',
|
41
|
+
'FLUENT_PACKAGE_LOG_FILE' => '',
|
42
|
+
}
|
39
43
|
@package_name = conf[:package_name]
|
40
44
|
@service_name = conf[:service_name]
|
41
45
|
|
@@ -153,10 +157,11 @@ module Diagtool
|
|
153
157
|
|
154
158
|
def _find_fluentbit_info()
|
155
159
|
### check if the td-agent-bit is run as daemon
|
156
|
-
|
160
|
+
|
161
|
+
stdout, _stderr, status = Open3.capture3("systemctl cat #{@service_name}")
|
157
162
|
if status.success?
|
158
163
|
if @precheck == false # SKip if precheck is true
|
159
|
-
File.open(@outdir+
|
164
|
+
File.open(@outdir+"/#{@service_name}_env.output", 'w') do |f|
|
160
165
|
f.puts(stdout)
|
161
166
|
end
|
162
167
|
end
|
@@ -180,8 +185,8 @@ module Diagtool
|
|
180
185
|
end
|
181
186
|
end
|
182
187
|
else
|
183
|
-
### check if the td-agent-bit is not run as daemon or run FluentdBit with customized script
|
184
|
-
stdout,
|
188
|
+
### check if the td-agent-bit is not run as daemon or run FluentdBit with customized script
|
189
|
+
stdout, _stderr, status = Open3.capture3('ps aux | grep fluent-bit | grep -v ".*\(grep\|diagtool\)"')
|
185
190
|
if status.success?
|
186
191
|
i = 0
|
187
192
|
stdout.split().each do | line |
|
@@ -403,16 +408,71 @@ module Diagtool
|
|
403
408
|
return output
|
404
409
|
end
|
405
410
|
|
411
|
+
def fluent_package?
|
412
|
+
@package_name == "fluent-package"
|
413
|
+
end
|
414
|
+
|
415
|
+
def match_platform?(platforms_option)
|
416
|
+
if Diagtool.windows?
|
417
|
+
platforms_option == "windows_platforms"
|
418
|
+
else
|
419
|
+
platforms_option == "not_windows_platforms"
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
def gemfile_path
|
424
|
+
if fluent_package?
|
425
|
+
"/opt/fluent/share/Gemfile"
|
426
|
+
else
|
427
|
+
"/opt/td-agent/share/Gemfile"
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
def collect_bundled_plugins
|
432
|
+
File.read(gemfile_path).lines(chomp: true).grep(/\Agem "fluent-plugin-/).collect do |line|
|
433
|
+
gem_name = line[/\Agem "(fluent-plugin-.+?)"/, 1]
|
434
|
+
platforms_option = line[/platforms: (\w+)/, 1]
|
435
|
+
next gem_name, platforms_option
|
436
|
+
end.select do |gem_name, platforms_option|
|
437
|
+
platforms_option.nil? || match_platform?(platforms_option)
|
438
|
+
end.collect do |gem_name, platforms_option|
|
439
|
+
gem_name
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
def collect_manually_installed_gems(gemlist_path)
|
444
|
+
installed_gems = File.read(gemlist_path).lines(chomp: true).collect do |line|
|
445
|
+
line.split.first
|
446
|
+
end
|
447
|
+
bundled_plugins = collect_bundled_plugins
|
448
|
+
bundled_gem_path = File.join(@outdir, "gem_bundled_list.output")
|
449
|
+
File.open(bundled_gem_path, 'w') do |f|
|
450
|
+
f.puts(bundled_plugins.join("\n"))
|
451
|
+
end
|
452
|
+
local_gem_path = File.join(@outdir, "gem_local_list.output")
|
453
|
+
# the folloing gems are not collected as bundled plugins
|
454
|
+
masked_gems = ["fluentd", "fluent-config-regexp-type", "fluent-logger", "fluent-diagtool"]
|
455
|
+
File.open(local_gem_path, 'w') do |f|
|
456
|
+
f.puts((installed_gems - bundled_plugins - masked_gems).join("\n"))
|
457
|
+
end
|
458
|
+
return {:bundled => bundled_gem_path, :local => local_gem_path}
|
459
|
+
end
|
460
|
+
|
406
461
|
def collect_tdgems()
|
407
462
|
output = @outdir+'/tdgem_list.output'
|
408
|
-
command = if
|
463
|
+
command = if fluent_package?
|
409
464
|
"fluent-gem"
|
410
465
|
else
|
411
466
|
"td-agent-gem"
|
412
467
|
end
|
413
|
-
stdout, stderr, status = Open3.capture3("#{command} list
|
468
|
+
stdout, stderr, status = Open3.capture3("#{command} list")
|
469
|
+
gems = stdout.each_line(chomp: true).select do |line|
|
470
|
+
line.include?("fluent")
|
471
|
+
end.collect do |line|
|
472
|
+
line.split.first
|
473
|
+
end
|
414
474
|
File.open(output, 'w') do |f|
|
415
|
-
f.puts(
|
475
|
+
f.puts(gems.join("\n"))
|
416
476
|
end
|
417
477
|
return output
|
418
478
|
end
|
@@ -14,15 +14,31 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
module Diagtool
|
18
|
+
ON_WINDOWS = /mingw/.match?(RUBY_PLATFORM)
|
19
|
+
def self.windows?
|
20
|
+
ON_WINDOWS
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
17
24
|
require 'logger'
|
18
25
|
require 'fileutils'
|
19
26
|
require 'fluent/diagtool/collectutils'
|
20
27
|
require 'fluent/diagtool/maskutils'
|
21
28
|
require 'fluent/diagtool/validutils'
|
29
|
+
require 'fluent/diagtool/windows/diagutils' if Diagtool.windows?
|
22
30
|
include Diagtool
|
23
31
|
|
24
32
|
module Diagtool
|
25
33
|
class DiagUtils
|
34
|
+
# TODO: Consider making the logic of this class more abstract and
|
35
|
+
# cutting out the unix-specific logic into a separate module as well.
|
36
|
+
# (Currently, very limited features are supported for Windows.
|
37
|
+
# In order to reduce impact on the existing logic for Unix-like.
|
38
|
+
# only Windows-specific logic is separated into the module, for now.
|
39
|
+
# In the future, the implementation of this class should be more abstract.)
|
40
|
+
prepend Windows::PlatformSpecificDiagUtils if Diagtool.windows?
|
41
|
+
|
26
42
|
def initialize(params)
|
27
43
|
time = Time.new
|
28
44
|
@time_format = time.strftime("%Y%m%d%0k%M%0S")
|
@@ -33,12 +49,22 @@ module Diagtool
|
|
33
49
|
"netstat -plan",
|
34
50
|
"netstat -s",
|
35
51
|
]
|
36
|
-
if
|
37
|
-
|
38
|
-
|
52
|
+
if @conf[:type] == "fluentd"
|
53
|
+
if fluent_package?
|
54
|
+
@conf[:package_name] = "fluent-package"
|
55
|
+
@conf[:service_name] = "fluentd"
|
56
|
+
else
|
57
|
+
@conf[:package_name] = "td-agent"
|
58
|
+
@conf[:service_name] = "td-agent"
|
59
|
+
end
|
39
60
|
else
|
40
|
-
|
41
|
-
|
61
|
+
if fluentbit_package?
|
62
|
+
@conf[:package_name] = "fluent-bit"
|
63
|
+
@conf[:service_name] = "fluent-bit"
|
64
|
+
else
|
65
|
+
@conf[:package_name] = "td-agent-bit"
|
66
|
+
@conf[:service_name] = "td-agent-bit"
|
67
|
+
end
|
42
68
|
end
|
43
69
|
end
|
44
70
|
|
@@ -123,9 +149,24 @@ module Diagtool
|
|
123
149
|
tdconf = c.collect_tdconf()
|
124
150
|
diaglogger_info("[Collect] config file is stored in #{tdconf}")
|
125
151
|
|
126
|
-
|
127
|
-
|
128
|
-
|
152
|
+
case @conf[:type]
|
153
|
+
when 'fluentd'
|
154
|
+
diaglogger_info("[Collect] Collecting #{@conf[:package_name]} gem information...")
|
155
|
+
tdgem = c.collect_tdgems()
|
156
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} gem information is stored in #{tdgem}")
|
157
|
+
gem_info = c.collect_manually_installed_gems(tdgem)
|
158
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} gem information (bundled by default) is stored in #{gem_info[:bundled]}")
|
159
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} manually installed gem information is stored in #{gem_info[:local]}")
|
160
|
+
local_gems = File.read(gem_info[:local]).lines(chomp: true)
|
161
|
+
unless local_gems == [""]
|
162
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} manually installed gems:")
|
163
|
+
local_gems.each do |gem|
|
164
|
+
diaglogger_info("[Collect] * #{gem}")
|
165
|
+
end
|
166
|
+
end
|
167
|
+
when 'fluentbit'
|
168
|
+
# nothing to do!
|
169
|
+
end
|
129
170
|
|
130
171
|
diaglogger_info("[Collect] Collecting config file of OS log...")
|
131
172
|
oslog = c.collect_oslog()
|
@@ -324,5 +365,9 @@ module Diagtool
|
|
324
365
|
def fluent_package?
|
325
366
|
File.exist?("/etc/fluent/fluentd.conf") || File.exist?("/opt/fluent/bin/fluentd")
|
326
367
|
end
|
368
|
+
|
369
|
+
def fluentbit_package?
|
370
|
+
File.exist?("/etc/fluent-bit/fluent-bit.conf") || File.exist?("/opt/fluent-bit/bin/fluent-bit")
|
371
|
+
end
|
327
372
|
end
|
328
373
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Diagtool
|
18
|
+
module Windows
|
19
|
+
module PlatformSpecificCollectUtils
|
20
|
+
def _find_fluentd_info()
|
21
|
+
# Not supported yet.
|
22
|
+
end
|
23
|
+
|
24
|
+
def _find_fluentbit_info()
|
25
|
+
# Not supported yet.
|
26
|
+
end
|
27
|
+
|
28
|
+
def _find_os_info()
|
29
|
+
# Not supported yet.
|
30
|
+
return {}
|
31
|
+
end
|
32
|
+
|
33
|
+
def gemfile_path
|
34
|
+
if fluent_package?
|
35
|
+
File.join(ENV["FLUENT_PACKAGE_TOPDIR"], "share/Gemfile")
|
36
|
+
else
|
37
|
+
File.join(ENV["TD_AGENT_TOPDIR"], "share/Gemfile")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'logger'
|
18
|
+
require 'fileutils'
|
19
|
+
require 'fluent/diagtool/collectutils'
|
20
|
+
|
21
|
+
module Diagtool
|
22
|
+
module Windows
|
23
|
+
module PlatformSpecificDiagUtils
|
24
|
+
def fluent_package?
|
25
|
+
ENV.key?("FLUENT_PACKAGE_TOPDIR")
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_precheck()
|
29
|
+
raise "[Precheck] Precheck feature is not supported on Windows."
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_diagtool()
|
33
|
+
@conf[:time] = @time_format
|
34
|
+
@conf[:workdir] = @conf[:basedir] + '/' + @time_format
|
35
|
+
@conf[:outdir] = @conf[:workdir] + '/output'
|
36
|
+
FileUtils.mkdir_p(@conf[:workdir])
|
37
|
+
FileUtils.mkdir_p(@conf[:outdir])
|
38
|
+
diaglog = @conf[:workdir] + '/diagtool.output'
|
39
|
+
|
40
|
+
@logger = Logger.new(STDOUT, formatter: proc {|severity, datetime, progname, msg|
|
41
|
+
"#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
|
42
|
+
})
|
43
|
+
@logger_file = Logger.new(diaglog, formatter: proc {|severity, datetime, progname, msg|
|
44
|
+
"#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
|
45
|
+
})
|
46
|
+
diaglogger_info("Parsing command options...")
|
47
|
+
diaglogger_info(" Option : Output directory = #{@conf[:basedir]}")
|
48
|
+
|
49
|
+
loglevel = 'WARN'
|
50
|
+
diaglogger_info("Initializing parameters...")
|
51
|
+
c = CollectUtils.new(@conf, loglevel)
|
52
|
+
|
53
|
+
diaglogger_info("[Collect] Collecting #{@conf[:package_name]} gem information...")
|
54
|
+
tdgem = c.collect_tdgems()
|
55
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} gem information is stored in #{tdgem}")
|
56
|
+
|
57
|
+
gem_info = c.collect_manually_installed_gems(tdgem)
|
58
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} gem information (bundled by default) is stored in #{gem_info[:bundled]}")
|
59
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} manually installed gem information is stored in #{gem_info[:local]}")
|
60
|
+
local_gems = File.read(gem_info[:local]).lines(chomp: true)
|
61
|
+
unless local_gems == [""]
|
62
|
+
diaglogger_info("[Collect] #{@conf[:package_name]} manually installed gems:")
|
63
|
+
local_gems.each do |gem|
|
64
|
+
diaglogger_info("[Collect] * #{gem}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def parse_diagconf(params)
|
70
|
+
options = {
|
71
|
+
:precheck => '', :basedir => '', :type =>'', :mask => '', :words => [], :wfile => '', :seed => '', :tdconf =>'', :tdlog => ''
|
72
|
+
}
|
73
|
+
|
74
|
+
supported_options = [:type, :output]
|
75
|
+
|
76
|
+
unless params[:type] == nil || params[:type] == 'fluentd'
|
77
|
+
raise "fluentd type '-t' only supports 'fluentd' on Windows."
|
78
|
+
end
|
79
|
+
options[:type] = 'fluentd'
|
80
|
+
|
81
|
+
if params[:output] != nil
|
82
|
+
if Dir.exist?(params[:output])
|
83
|
+
options[:basedir] = params[:output]
|
84
|
+
else
|
85
|
+
raise "output directory '#{params[:output]}' does not exist"
|
86
|
+
end
|
87
|
+
else
|
88
|
+
raise "output directory '-o' must be specified"
|
89
|
+
end
|
90
|
+
|
91
|
+
params.keys.each do |option|
|
92
|
+
unless supported_options.include?(option)
|
93
|
+
raise "#{option} is not supported on Windows."
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
return options
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-diagtool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kubotat
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|
@@ -66,11 +66,13 @@ files:
|
|
66
66
|
- lib/fluent/diagtool/maskutils.rb
|
67
67
|
- lib/fluent/diagtool/validutils.rb
|
68
68
|
- lib/fluent/diagtool/version.rb
|
69
|
+
- lib/fluent/diagtool/windows/collectutils.rb
|
70
|
+
- lib/fluent/diagtool/windows/diagutils.rb
|
69
71
|
homepage: https://github.com/fluent/diagtool/tree/dev
|
70
72
|
licenses:
|
71
73
|
- Apache-2.0
|
72
74
|
metadata: {}
|
73
|
-
post_install_message:
|
75
|
+
post_install_message:
|
74
76
|
rdoc_options: []
|
75
77
|
require_paths:
|
76
78
|
- lib
|
@@ -85,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
87
|
- !ruby/object:Gem::Version
|
86
88
|
version: '0'
|
87
89
|
requirements: []
|
88
|
-
rubygems_version: 3.4.
|
89
|
-
signing_key:
|
90
|
+
rubygems_version: 3.4.19
|
91
|
+
signing_key:
|
90
92
|
specification_version: 4
|
91
93
|
summary: Diagnostic Tool for Fluentd
|
92
94
|
test_files: []
|