fluent-diagtool 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfb1e90d1be9a7723371f6ea3cf72ea4eec822d732e2d940e54871cf20ce02d0
4
- data.tar.gz: bbc10274d97eef4e0c79b5da843947389607519dd8f34e66ebc775ecf7171736
3
+ metadata.gz: 44527fe77df5bcf3b4888b5a697f796460a69e3873561c88b278e318f5c83cd8
4
+ data.tar.gz: 6052777c8a6930f4dde4bc1fa40bd3a62eba4541253488d419f21f02ab11568a
5
5
  SHA512:
6
- metadata.gz: 1917964e68291c9a4cef64fca18139a1235f3a8bacc6eac8071881e4303cf4b18a0217fd0a8085641e4881a4847542b53b4b2390af8a50298f72259f3d6cba9b
7
- data.tar.gz: d8c90fa8083e37510c55e1ad3059767585bc0b9c9adff3709e58d0e4225329c4ef4b5e5509a1323ab7af4e48101bf06384db82c56ad1dce99cbef6e512218a08
6
+ metadata.gz: 1d03c3277e64b402db14aaa6f530c02ceb640ff57b53e170fc2633e63d23a53b4b8f604a292b4a958e74035ccb6dac4f02b782ee58e1ea579e916cf3ba050012
7
+ data.tar.gz: b2d8da326cab4181b391758e9e7fa7cfb8682580726b0921afcc08a6fc8788db818bd325c8a24dcc8ee83975d69d058f306bc8d852b8417a2a4d9f3341e38fd0
@@ -36,7 +36,9 @@ module Diagtool
36
36
  'FLUENT_CONF' => '',
37
37
  'TD_AGENT_LOG_FILE' => ''
38
38
  }
39
-
39
+ @package_name = conf[:package_name]
40
+ @service_name = conf[:service_name]
41
+
40
42
  case @type
41
43
  when 'fluentd'
42
44
  _find_fluentd_info()
@@ -52,7 +54,7 @@ module Diagtool
52
54
  @tdconf = @tdenv['FLUENT_CONF'].split('/')[-1]
53
55
  @tdconf_path = @tdenv['FLUENT_CONF'].gsub(@tdconf,'')
54
56
  else
55
- raise "The path of td-agent configuration file need to be specified." if conf[:precheck] == false
57
+ raise "The path of #{@package_name} configuration file need to be specified." if conf[:precheck] == false
56
58
  end
57
59
  end
58
60
  if not conf[:tdlog].empty?
@@ -62,10 +64,13 @@ module Diagtool
62
64
  if not @tdenv['TD_AGENT_LOG_FILE'].empty?
63
65
  @tdlog = @tdenv['TD_AGENT_LOG_FILE'].split('/')[-1]
64
66
  @tdlog_path = @tdenv['TD_AGENT_LOG_FILE'].gsub(@tdlog,'')
67
+ elsif not @tdenv['FLUENT_PACKAGE_LOG_FILE'].empty?
68
+ @tdlog = @tdenv['FLUENT_PACKAGE_LOG_FILE'].split('/')[-1]
69
+ @tdlog_path = @tdenv['FLUENT_PACKAGE_LOG_FILE'].gsub(@tdlog,'')
65
70
  else
66
71
  case @type
67
72
  when 'fluentd'
68
- raise "The path of td-agent log file need to be specified." if conf[:precheck] == false
73
+ raise "The path of #{@package_name} log file need to be specified." if conf[:precheck] == false
69
74
  when 'fluentbit'
70
75
  @logger.warn("FluentBit logs are redirected to the standard output interface ")
71
76
  end
@@ -81,10 +86,10 @@ module Diagtool
81
86
  @logger.info("Loading the environment parameters...")
82
87
  @logger.info(" operating system = #{@osenv['Operating System']}")
83
88
  @logger.info(" kernel version = #{@osenv['Kernel']}")
84
- @logger.info(" td-agent conf path = #{@tdconf_path}")
85
- @logger.info(" td-agent conf file = #{@tdconf}")
86
- @logger.info(" td-agent log path = #{@tdlog_path}")
87
- @logger.info(" td-agent log = #{@tdlog}")
89
+ @logger.info(" #{@package_name} conf path = #{@tdconf_path}")
90
+ @logger.info(" #{@package_name} conf file = #{@tdconf}")
91
+ @logger.info(" #{@package_name} log path = #{@tdlog_path}")
92
+ @logger.info(" #{@package_name} log = #{@tdlog}")
88
93
  end
89
94
 
90
95
  def _find_os_info()
@@ -104,7 +109,7 @@ module Diagtool
104
109
 
105
110
  def _find_fluentd_info()
106
111
  ### check if the td-agent is run as daemon
107
- stdout, stderr, status = Open3.capture3('systemctl cat td-agent')
112
+ stdout, stderr, status = Open3.capture3("systemctl cat #{@service_name}")
108
113
  if status.success?
109
114
  if @precheck == false # SKip if precheck is true
110
115
  File.open(@outdir+'/td-agent_env.output', 'w') do |f|
@@ -365,7 +370,7 @@ module Diagtool
365
370
  FileUtils.cp(@oslog_path+@syslog, target_dir)
366
371
  return target_dir+@syslog
367
372
  else
368
- @logger.warn("Can not find OS log file in #{oslog} or #{syslog}")
373
+ @logger.warn("Can not find OS log file in #{@oslog} or #{@syslog}")
369
374
  end
370
375
  end
371
376
 
@@ -400,7 +405,12 @@ module Diagtool
400
405
 
401
406
  def collect_tdgems()
402
407
  output = @outdir+'/tdgem_list.output'
403
- stdout, stderr, status = Open3.capture3("td-agent-gem list | grep fluent")
408
+ command = if @package_name == "fluent-package"
409
+ "fluent-gem"
410
+ else
411
+ "td-agent-gem"
412
+ end
413
+ stdout, stderr, status = Open3.capture3("#{command} list | grep fluent")
404
414
  File.open(output, 'w') do |f|
405
415
  f.puts(stdout)
406
416
  end
@@ -33,6 +33,13 @@ module Diagtool
33
33
  "netstat -plan",
34
34
  "netstat -s",
35
35
  ]
36
+ if fluent_package?
37
+ @conf[:package_name] = "fluent-package"
38
+ @conf[:service_name] = "fluentd"
39
+ else
40
+ @conf[:package_name] = "td-agent"
41
+ @conf[:service_name] = "td-agent"
42
+ end
36
43
  end
37
44
 
38
45
  def run_precheck()
@@ -46,16 +53,16 @@ module Diagtool
46
53
  prechecklog.info("[Precheck] Check OS parameters...")
47
54
  prechecklog.info("[Precheck] operating system = #{c_env[:os]}")
48
55
  prechecklog.info("[Precheck] kernel version = #{c_env[:kernel]}")
49
- prechecklog.info("[Precheck] Check td-agent parameters...")
50
- prechecklog.info("[Precheck] td-agent conf path = #{c_env[:tdconf_path]}")
51
- prechecklog.info("[Precheck] td-agent conf file = #{c_env[:tdconf]}")
52
- prechecklog.info("[Precheck] td-agent log path = #{c_env[:tdlog_path]}")
53
- prechecklog.info("[Precheck] td-agent log = #{c_env[:tdlog]}")
56
+ prechecklog.info("[Precheck] Check #{@conf[:package_name]} parameters...")
57
+ prechecklog.info("[Precheck] #{@conf[:package_name]} conf path = #{c_env[:tdconf_path]}")
58
+ prechecklog.info("[Precheck] #{@conf[:package_name]} conf file = #{c_env[:tdconf]}")
59
+ prechecklog.info("[Precheck] #{@conf[:package_name]} log path = #{c_env[:tdlog_path]}")
60
+ prechecklog.info("[Precheck] #{@conf[:package_name]} log = #{c_env[:tdlog]}")
54
61
  if c_env[:tdconf_path] == nil || c_env[:tdconf] == nil
55
- prechecklog.warn("[Precheck] can not find td-agent conf path: please run diagtool command with -c /path/to/<td-agent conf file>")
62
+ prechecklog.warn("[Precheck] can not find #{@conf[:package_name]} conf path: please run diagtool command with -c /path/to/<#{@conf[:package_name]} conf file>")
56
63
  end
57
64
  if c_env[:tdlog_path] == nil || c_env[:tdlog] == nil
58
- prechecklog.warn("[Precheck] can not find td-agent log path: please run diagtool command with -l /path/to/<td-agent log file>")
65
+ prechecklog.warn("[Precheck] can not find #{@conf[:package_name]} log path: please run diagtool command with -l /path/to/<#{@conf[:package_name]} log file>")
59
66
  end
60
67
  if c_env[:tdconf_path] != nil && c_env[:tdconf] != nil && c_env[:tdlog_path] != nil && c_env[:tdlog] != nil
61
68
  prechecklog.info("[Precheck] Precheck completed. You can run diagtool command without -c and -l options")
@@ -90,35 +97,35 @@ module Diagtool
90
97
  diaglogger_info("[Collect] Loading the environment parameters...")
91
98
  diaglogger_info("[Collect] operating system = #{c_env[:os]}")
92
99
  diaglogger_info("[Collect] kernel version = #{c_env[:kernel]}")
93
- diaglogger_info("[Collect] td-agent conf path = #{c_env[:tdconf_path]}")
94
- diaglogger_info("[Collect] td-agent conf file = #{c_env[:tdconf]}")
95
- diaglogger_info("[Collect] td-agent log path = #{c_env[:tdlog_path]}")
96
- diaglogger_info("[Collect] td-agent log = #{c_env[:tdlog]}")
100
+ diaglogger_info("[Collect] #{@conf[:package_name]} conf path = #{c_env[:tdconf_path]}")
101
+ diaglogger_info("[Collect] #{@conf[:package_name]} conf file = #{c_env[:tdconf]}")
102
+ diaglogger_info("[Collect] #{@conf[:package_name]} log path = #{c_env[:tdlog_path]}")
103
+ diaglogger_info("[Collect] #{@conf[:package_name]} log = #{c_env[:tdlog]}")
97
104
  m = MaskUtils.new(@conf, loglevel)
98
105
  v = ValidUtils.new(loglevel)
99
106
 
100
- diaglogger_info("[Collect] Collecting log files of td-agent...")
107
+ diaglogger_info("[Collect] Collecting log files of #{@conf[:package_name]}...")
101
108
  case @type
102
109
  when 'fluentd'
103
110
  tdlog = c.collect_tdlog()
104
- diaglogger_info("[Collect] log files of td-agent are stored in #{tdlog}")
111
+ diaglogger_info("[Collect] log files of #{@conf[:package_name]} are stored in #{tdlog}")
105
112
  when 'fleuntbit'
106
113
  if tdlog.empty?
107
114
  diaglogger_info("FluentBit logs are redirected to the standard output interface ")
108
115
  tdlog = ''
109
116
  else
110
117
  tdlog = c.collect_tdlog()
111
- diaglogger_info("[Collect] log files of td-agent are stored in #{tdlog}")
118
+ diaglogger_info("[Collect] log files of #{@conf[:package_name]} are stored in #{tdlog}")
112
119
  end
113
120
  end
114
121
 
115
- diaglogger_info("[Collect] Collecting config file of td-agent...")
122
+ diaglogger_info("[Collect] Collecting config file of #{@conf[:package_name]}...")
116
123
  tdconf = c.collect_tdconf()
117
124
  diaglogger_info("[Collect] config file is stored in #{tdconf}")
118
125
 
119
- diaglogger_info("[Collect] Collecting td-agent gem information...")
126
+ diaglogger_info("[Collect] Collecting #{@conf[:package_name]} gem information...")
120
127
  tdgem = c.collect_tdgems()
121
- diaglogger_info("[Collect] td-agent gem information is stored in #{tdgem}")
128
+ diaglogger_info("[Collect] #{@conf[:package_name]} gem information is stored in #{tdgem}")
122
129
 
123
130
  diaglogger_info("[Collect] Collecting config file of OS log...")
124
131
  oslog = c.collect_oslog()
@@ -157,11 +164,11 @@ module Diagtool
157
164
  ###
158
165
  # Correct information to be validated
159
166
  ###
160
- diaglogger_info("[Collect] Collecting systctl information...")
167
+ diaglogger_info("[Collect] Collecting sysctl information...")
161
168
  sysctl = c.collect_cmd_output("sysctl -a")
162
169
  diaglogger_info("[Collect] sysctl information is stored in #{sysctl}")
163
170
 
164
- diaglogger_info("[Valid] Validating systctl information...")
171
+ diaglogger_info("[Valid] Validating sysctl information...")
165
172
  ret, sysctl = v.valid_sysctl(sysctl)
166
173
  list = sysctl.keys
167
174
  list.each do |k|
@@ -186,7 +193,7 @@ module Diagtool
186
193
 
187
194
  if @conf[:mask] == 'yes'
188
195
  tdconf.each { | file |
189
- diaglogger_info("[Mask] Masking td-agent config file : #{file}...")
196
+ diaglogger_info("[Mask] Masking #{@conf[:package_name]} config file : #{file}...")
190
197
  m.mask_tdlog(file, clean = true)
191
198
  }
192
199
  end
@@ -194,7 +201,7 @@ module Diagtool
194
201
  if @conf[:mask] == 'yes'
195
202
  if tdlog != nil
196
203
  tdlog.each { | file |
197
- diaglogger_info("[Mask] Masking td-agent log file : #{file}...")
204
+ diaglogger_info("[Mask] Masking #{@conf[:package_name]} log file : #{file}...")
198
205
  filename = file.split("/")[-1]
199
206
  if filename.include?(".gz")
200
207
  m.mask_tdlog_gz(file, clean = true)
@@ -229,7 +236,7 @@ module Diagtool
229
236
  if Dir.exist?(params[:output])
230
237
  options[:basedir] = params[:output]
231
238
  else
232
- raise "output directory '#{basedir}' does not exist"
239
+ raise "output directory '#{params[:output]}' does not exist"
233
240
  end
234
241
  else
235
242
  raise "output directory '-o' must be specified"
@@ -313,5 +320,9 @@ module Diagtool
313
320
  @logger.error(str)
314
321
  @logger_file.error(str)
315
322
  end
323
+
324
+ def fluent_package?
325
+ File.exist?("/etc/fluent/fluentd.conf") || File.exist?("/opt/fluent/bin/fluentd")
326
+ end
316
327
  end
317
328
  end
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module Diagtool
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kubotat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-29 00:00:00.000000000 Z
11
+ date: 2023-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils
@@ -85,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.7.6.2
88
+ rubygems_version: 3.4.10
90
89
  signing_key:
91
90
  specification_version: 4
92
91
  summary: Diagnostic Tool for Fluentd