fluent-diagtool 0.1.4 → 0.1.9

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: 180c7e58ee03d59778640b05042fca84197936b7bdd2b2fff236ef86f0639ef4
4
- data.tar.gz: b1ffccfb3a92af08dfa17fe4796e7a229a25d0abe1bf0f1362ac4618bf5c99f0
3
+ metadata.gz: e5be26bf333469e8c3c4eed5be22a33d05f8a37306d5e93067c10134a9415cb3
4
+ data.tar.gz: 128d6aa7ff697b5fcae2669a8e14dffb96f52ab360d4585313942343432a89b8
5
5
  SHA512:
6
- metadata.gz: b482bfc75cda3285976980d2f8a04abfe848dd9bb6ff4992c0760f871f237811fbae361dfb15075482a781ec284974d7471937423e3400f0b576bc3dff03ccf0
7
- data.tar.gz: 5810ec1b6f37b5ccf49f53bd8271beb885dde8c7b9e8be33aed38b5d137e8952085aaddbb8b7717e58535bd36decd19e1babde94a2ba78d07ba41d1ffd0cf9c5
6
+ metadata.gz: 4165a154d754ac8d7d338bd4adaa681059579c6f7c7410badefdb34d9ab260211e5807a54dcd602bb3f765a8265aa40a2ff8b95d5ecb82c5ccb8931be198c6a3
7
+ data.tar.gz: c0f8916a1399438aa50a15deb90f59321e5e02fc5902c04d04ed1ac98701f8f1bc109de5fa79ff9167169a9e848310f7988a6a521af95bb74dade68ddbdbc4e0
data/README.md CHANGED
@@ -17,8 +17,7 @@ The scope of data collection:
17
17
  - snapshot of current process(ps)
18
18
  - network conectivity status/stats(netstat -plan/netstat -s)
19
19
  - memory information(/proc/meminfo)
20
- <br>
21
- (*) The diagtool automatically gather the path of td-agent configuration files and log files from td-agent daemon and use them during data collection.
20
+ <br>
22
21
 
23
22
  ## Prerequisite
24
23
  The diagtool provides support for td-agent based installation running on Linux OS. The td-agent is a stable distribution package of Fluentd.
@@ -43,13 +42,54 @@ Successfully installed fluent-diagtool-0.1.2
43
42
  ```
44
43
  # diagtool --help
45
44
  Usage: /usr/local/bin/diagtool -o OUTPUT_DIR -m {yes | no} -w {word1,[word2...]} -f {listfile} -s {hash seed}
45
+ --precheck Run Precheck (Optional)
46
46
  -o, --output DIR Output directory (Mandatory)
47
47
  -m, --mask yes|no Enable mask function (Optional : Default=no)
48
48
  -w, --word-list word1,word2 Provide a list of user-defined words which will to be masked (Optional : Default=None)
49
- -f, --word-file listfile provide a file which describes a List of user-defined words (Optional : Default=None)
49
+ -f, --word-file list_file provide a file which describes a List of user-defined words (Optional : Default=None)
50
50
  -s, --hash-seed seed provide a word which will be used when generate the mask (Optional : Default=None)
51
+ -c, --conf config_file provide a full path of td-agent configuration file (Optional : Default=None)
52
+ -l, --log log_file provide a full path of td-agent log file (Optional : Default=None)
51
53
  ```
52
- The list of user-defined words can be specified both -e option and -f option.
54
+ ### Pre-check
55
+ The diagtool automatically extract the path of td-agent configuration and log files from td-agent daemon and use them during data collection if the td-agent is managed as daemon. The precheck options provides the function to confirm if the diagtool could gather the td-agent information as expected.
56
+ The following command output shows the case when the diagtool successfully gather information from daemon.
57
+ ```
58
+ # diagtool --precheck
59
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] Check OS parameters...
60
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] operating system = CentOS Linux 8 (Core)
61
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] kernel version = Linux 4.18.0-147.el8.x86_64
62
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] Check td-agent parameters...
63
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] td-agent conf path = /etc/td-agent/
64
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] td-agent conf file = td-agent.conf
65
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] td-agent log path = /var/log/td-agent/
66
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] td-agent log = td-agent.log
67
+ 2020-05-28 00:39:02 -0400: [Diagtool] [INFO] [Precheck] Precheck completed. You can run diagtool command without -c and -l options
68
+ ```
69
+ In some cases, users do not manage td-agent as daemon but use own script to run td-agent with command line options. In that cases, users need to speccify the path of td-agent configuration and log files with -c and -l options respectively.
70
+ The following example shows the precheck results when the diagtool is not able to extract the path of td-agent configuration and log files.
71
+ ```
72
+ # diagtool --precheck
73
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] Check OS parameters...
74
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] operating system = CentOS Linux 8 (Core)
75
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] kernel version = Linux 4.18.0-147.5.1.el8_1.x86_64
76
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] Check td-agent parameters...
77
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] td-agent conf path =
78
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] td-agent conf file =
79
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] td-agent log path =
80
+ 2020-05-28 05:45:14 +0000: [Diagtool] [INFO] [Precheck] td-agent log =
81
+ 2020-05-28 05:45:14 +0000: [Diagtool] [WARN] [Precheck] can not find td-agent conf path: please run diagtool command with -c /path/to/<td-agent conf file>
82
+ 2020-05-28 05:45:14 +0000: [Diagtool] [WARN] [Precheck] can not find td-agent log path: please run diagtool command with -l /path/to/<td-agent log file>
83
+ ```
84
+
85
+ ### Run diagtool
86
+
87
+ #### The "@include" directive in td-agent configuration file
88
+ The "@include" directive is a function to reuse configuration defined in another configuration files. The diagtool read the td-agent configuration and collect the files described in "@include" directive as well. The details of "@include" directive are described in followed url:
89
+ https://docs.fluentd.org/configuration/config-file#6-re-use-your-config-the-include-directive
90
+
91
+ #### User defined words to be masked
92
+ The user-defined words can be specified both -e option and -f option and the words are merged when both options are selected.
53
93
  The format of user-defined words list file specified in -f option should be followed format.
54
94
  ```
55
95
  # cat word_list_sample
@@ -116,7 +156,7 @@ NOTE: When user specified the keywork, only the exact match words will be masked
116
156
  2020-05-12 18:21:22 -0400: [Diagtool] [INFO] [Mask] Export mask log file : ./mask_20200512182119.json
117
157
  2020-05-12 18:21:22 -0400: [Diagtool] [INFO] [Collect] Generate tar file /tmp/work1/diagout-20200512182119.tar.gz
118
158
  ```
119
- ## Mask Function
159
+ #### Mask Function
120
160
  When run diagtool with mask option, the log of mask is also created in 'mask_{timestamp}.json' file. Users are able to confirm how the mask was generated on each files.
121
161
  The diagtool provides hash-seed option with '-s'. When hash-seed is specified, the mask will be generated with original word and hash-seed so that users could use unique mask value.
122
162
  #### Mask sample - IP address: IPv4_{md5hash}
@@ -0,0 +1,87 @@
1
+ require 'optparse'
2
+ require 'logger'
3
+ require '../lib/diagutils'
4
+ include Diagtool
5
+
6
+ logger = Logger.new(STDOUT, formatter: proc {|severity, datetime, progname, msg|
7
+ "#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
8
+ })
9
+
10
+ output_dir = '../output'
11
+ mask = 'yes'
12
+ exlist= Array.new
13
+
14
+ opt = OptionParser.new
15
+ opt.banner = "Usage: #{$0} -o OUTPUT_DIR -m {yes | no} -e {word1,[word2...]} -f {listfile}"
16
+ opt.on('-o','--output DIR', String, 'Output directory (Default=./output)') { |o|
17
+ output_dir = o
18
+ }
19
+ opt.on('-m','--mask YES|NO', String, 'Enable mask function (Default=True)') { |m|
20
+ if m == 'yes' || m == 'no'
21
+ mask = m
22
+ else
23
+ logger.error("Invalid value '#{m}' : -m | --mask should be yes or no")
24
+ exit!
25
+ end
26
+ }
27
+ opt.on('-e','--exclude-list LIST', Array, 'Provide a list of exclude words which will to be masked (Default=None)') { |e| exlist += e }
28
+ opt.on('-f','--exclude-file FILE', String, 'provide a file which describes a List of exclude words (Default=None)') { |f|
29
+ if File.exist?(f)
30
+ File.readlines(f).each do |l|
31
+ exlist.append(l.gsub(/\n/,''))
32
+ end
33
+ else
34
+ logger.error("No such file or directory")
35
+ exit!
36
+ end
37
+ }
38
+ opt.parse(ARGV)
39
+ exlist = exlist.uniq
40
+
41
+ logger.info("Parsing command options...")
42
+ logger.info(" Option : Output directory = #{output_dir}")
43
+ logger.info(" Option : Mask = #{mask}")
44
+ logger.info(" Option : Exclude list = #{exlist}")
45
+
46
+ logger.info("Initializing parameters...")
47
+ node1 = Diagutils.new(output_dir,exlist, 'INFO')
48
+
49
+ logger.info("Collecting log files of td-agent...")
50
+ tdlog = node1.collect_tdlog()
51
+ logger.info("log files of td-agent are stored in #{tdlog}")
52
+
53
+ logger.info("Collecting config file of td-agent...")
54
+ tdconf = node1.collect_tdconf()
55
+ logger.info("config file is stored in #{tdconf}")
56
+
57
+ logger.info("Collecting systctl information...")
58
+ sysctl = node1.collect_sysctl()
59
+ logger.info("sysctl information is stored in #{sysctl}")
60
+
61
+ logger.info("Collecting date/time information...")
62
+ ntp = node1.collect_ntp()
63
+ logger.info("date/time information is stored in #{ntp}")
64
+
65
+ logger.info("Collecting ulimit information...")
66
+ ulimit = node1.collect_ulimit()
67
+ logger.info("ulimit information is stored in #{ulimit}")
68
+
69
+ if mask == 'yes'
70
+ logger.info("Masking td-agent config file : #{tdconf}...")
71
+ node1.mask_tdconf(tdconf)
72
+ tdlog.each do | file |
73
+ logger.info("Masking td-agent log file : #{file}...")
74
+ filename = file.split("/")[-1]
75
+ if filename.include?(".gz")
76
+ node1.mask_tdlog_gz(file)
77
+ elsif
78
+ node1.mask_tdlog(file)
79
+ end
80
+ end
81
+ end
82
+
83
+ tar_file = node1.compress_output()
84
+ logger.info("Generate tar file #{tar_file}")
85
+
86
+
87
+
@@ -0,0 +1,2 @@
1
+ centos8101
2
+ centos8102
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_runtime_dependency("fileutils", ["~> 1.0"])
23
- spec.add_runtime_dependency("json", ["~> 2.1"])
22
+ spec.add_runtime_dependency("fileutils")
23
+ spec.add_runtime_dependency("json")
24
24
  end
@@ -22,7 +22,7 @@ module Diagtool
22
22
  class CollectUtils
23
23
  def initialize(conf, log_level)
24
24
  @logger = Logger.new(STDOUT, level: log_level, formatter: proc {|severity, datetime, progname, msg|
25
- "#{datetime}: [Diagutils] [#{severity}] #{msg}\n"
25
+ "#{datetime}: [Collectutils] [#{severity}] #{msg}\n"
26
26
  })
27
27
  @precheck = conf[:precheck]
28
28
  @time_format = conf[:time]
@@ -30,7 +30,7 @@ module Diagtool
30
30
  @workdir = conf[:workdir]
31
31
  @outdir = conf[:outdir]
32
32
 
33
- @tdenv = get_tdenv()
33
+ @tdenv = gen_tdenv()
34
34
  if not conf[:tdconf].empty?
35
35
  @tdconf = conf[:tdconf].split('/')[-1]
36
36
  @tdconf_path = conf[:tdconf].gsub(@tdconf,'')
@@ -53,9 +53,10 @@ module Diagtool
53
53
  raise "The path of td-agent log file need to be specified." if conf[:precheck] == false
54
54
  end
55
55
  end
56
- @osenv = get_osenv()
56
+ @osenv = gen_osenv()
57
57
  @oslog_path = '/var/log/'
58
58
  @oslog = 'messages'
59
+ @syslog = 'syslog'
59
60
  @sysctl_path = '/etc/'
60
61
  @sysctl = 'sysctl.conf'
61
62
 
@@ -68,7 +69,7 @@ module Diagtool
68
69
  @logger.info(" td-agent log = #{@tdlog}")
69
70
  end
70
71
 
71
- def get_osenv()
72
+ def gen_osenv()
72
73
  stdout, stderr, status = Open3.capture3('hostnamectl')
73
74
  os_dict = {}
74
75
  stdout.each_line { |l|
@@ -83,7 +84,7 @@ module Diagtool
83
84
  return os_dict
84
85
  end
85
86
 
86
- def get_tdenv()
87
+ def gen_tdenv()
87
88
  stdout, stderr, status = Open3.capture3('systemctl cat td-agent')
88
89
  env_dict = {}
89
90
  if status.success?
@@ -143,12 +144,45 @@ module Diagtool
143
144
  target_dir = @workdir+@tdconf_path
144
145
  FileUtils.mkdir_p(target_dir)
145
146
  FileUtils.cp(@tdconf_path+@tdconf, target_dir)
146
- return target_dir+@tdconf
147
+ conf = @workdir+@tdconf_path+@tdconf
148
+ conf_list = []
149
+ conf_list.push target_dir + @tdconf
150
+ File.readlines(conf).each { |line|
151
+ if line.include? '@include'
152
+ f = line.split()[1]
153
+ if f.start_with?(/\//) # /tmp/work1/b.conf
154
+ if f.include?('*')
155
+ Dir.glob(f).each { |ff|
156
+ conf_inc = target_dir + ff.gsub(/\//,'__')
157
+ FileUtils.cp(ff, conf_inc)
158
+ conf_list.push conf_inc
159
+ }
160
+ else
161
+ conf_inc = target_dir+f.gsub(/\//,'__')
162
+ FileUtils.cp(f, conf_inc)
163
+ conf_list.push conf_inc
164
+ end
165
+ else
166
+ f = f.gsub('./','') if f.include?('./')
167
+ if f.include?('*')
168
+ Dir.glob(@tdconf_path+f).each{ |ff|
169
+ conf_inc = target_dir + ff.gsub(@tdconf_path,'').gsub(/\//,'__')
170
+ FileUtils.cp(ff, conf_inc)
171
+ conf_list.push conf_inc
172
+ }
173
+ else
174
+ conf_inc = target_dir+f.gsub(/\//,'__')
175
+ FileUtils.cp(@tdconf_path+f, conf_inc)
176
+ conf_list.push conf_inc
177
+ end
178
+ end
179
+ end
180
+ }
181
+ return conf_list
147
182
  end
148
-
183
+
149
184
  def collect_tdlog()
150
185
  target_dir = @workdir+@tdlog_path
151
- p target_dir
152
186
  FileUtils.mkdir_p(target_dir)
153
187
  Dir.glob(@tdlog_path+@tdlog+'*').each{ |f|
154
188
  FileUtils.cp(f, target_dir)
@@ -156,77 +190,34 @@ module Diagtool
156
190
  return Dir.glob(target_dir+@tdlog+'*')
157
191
  end
158
192
 
159
- def collect_sysctl()
160
- target_dir = @workdir+@sysctl_path
161
- FileUtils.mkdir_p(target_dir)
162
- FileUtils.cp(@sysctl_path+@sysctl, target_dir)
163
- return target_dir+@sysctl
164
- end
165
-
166
193
  def collect_oslog()
167
194
  target_dir = @workdir+@oslog_path
168
195
  FileUtils.mkdir_p(target_dir)
169
- FileUtils.cp(@oslog_path+@oslog, target_dir)
170
- return target_dir+@oslog
171
- end
172
-
173
- def collect_ulimit()
174
- output = @outdir+'/ulimit_n.output'
175
- stdout, stderr, status = Open3.capture3("ulimit -n")
176
- File.open(output, 'w') do |f|
177
- f.puts(stdout)
178
- end
179
- return output
180
- end
181
-
182
- def collect_ps_eo()
183
- output = @outdir+'/ps_eo.output'
184
- stdout, stderr, status = Open3.capture3("ps -eo pid,ppid,stime,time,%mem,%cpu,cmd")
185
- File.open(output, 'w') do |f|
186
- f.puts(stdout)
196
+ if File.exist? @oslog_path+@oslog
197
+ FileUtils.cp(@oslog_path+@oslog, target_dir)
198
+ return target_dir+@oslog
199
+ elsif File.exist? @oslog_path+@syslog
200
+ FileUtils.cp(@oslog_path+@syslog, target_dir)
201
+ return target_dir+@syslog
202
+ else
203
+ @logger.warn("Can not find OS log file in #{oslog} or #{syslog}")
187
204
  end
188
- return output
189
205
  end
190
206
 
191
- def collect_meminfo()
192
- output = @outdir+'/meminfo.output'
193
- stdout, stderr, status = Open3.capture3("cat /proc/meminfo")
194
- File.open(output, 'w') do |f|
195
- f.puts(stdout)
196
- end
197
- return output
198
- end
199
-
200
- def collect_netstat_plan()
201
- output = @outdir+'/netstat_plan.output'
202
- stdout, stderr, status = Open3.capture3("netstat -plan")
203
- File.open(output, 'w') do |f|
204
- f.puts(stdout)
205
- end
206
- return output
207
- end
208
-
209
- def collect_netstat_s()
210
- output = @outdir+'/netstat_s.output'
211
- stdout, stderr, status = Open3.capture3("netstat -s")
212
- File.open(output, 'w') do |f|
213
- f.puts(stdout)
214
- end
215
- return output
216
- end
217
-
218
- def collect_ntp(command)
219
- output = @outdir+'/ntp_info.output'
220
- stdout_date, stderr_date, status_date = Open3.capture3("date")
221
- stdout_ntp, stderr_ntp, status_ntp = Open3.capture3("chronyc sources") if command == "chrony"
222
- stdout_ntp, stderr_ntp, status_ntp = Open3.capture3("ntpq -p") if command == "ntp"
223
- File.open(output, 'w') do |f|
224
- f.puts(stdout_date)
225
- f.puts(stdout_ntp)
207
+ def collect_cmd_output(cmd)
208
+ cmd_name = cmd.gsub(/\s/,'_').gsub(/\//,'-').gsub(',','_')
209
+ output = @outdir+'/'+cmd_name+'.txt'
210
+ stdout, stderr, status = Open3.capture3(cmd)
211
+ if status.success?
212
+ File.open(output, 'w') do |f|
213
+ f.puts(stdout)
214
+ end
215
+ else
216
+ @logger.warn("Command #{cmd} failed due to the following message - #{stderr.chomp}")
226
217
  end
227
218
  return output
228
219
  end
229
-
220
+
230
221
  def collect_tdgems()
231
222
  output = @outdir+'/tdgem_list.output'
232
223
  stdout, stderr, status = Open3.capture3("td-agent-gem list | grep fluent")
@@ -27,26 +27,12 @@ module Diagtool
27
27
  time = Time.new
28
28
  @time_format = time.strftime("%Y%m%d%0k%M%0S")
29
29
  @conf = parse_diagconf(params)
30
- #@conf[:time] = @time_format
31
- #@conf[:workdir] = @conf[:basedir] + '/' + @time_format
32
- #@conf[:outdir] = @conf[:workdir] + '/output'
33
-
34
- #FileUtils.mkdir_p(@conf[:workdir])
35
- #FileUtils.mkdir_p(@conf[:outdir])
36
-
37
- #diaglog = @conf[:workdir] + '/diagtool.output'
38
- #@masklog = './mask_' + @time_format + '.json'
39
- #@logger = Logger.new(STDOUT, formatter: proc {|severity, datetime, progname, msg|
40
- # "#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
41
- #})
42
- #@logger_file = Logger.new(diaglog, formatter: proc {|severity, datetime, progname, msg|
43
- # "#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
44
- #})
45
- #diaglogger_info("Parsing command options...")
46
- #diaglogger_info(" Option : Output directory = #{@conf[:basedir]}")
47
- #diaglogger_info(" Option : Mask = #{@conf[:mask]}")
48
- #diaglogger_info(" Option : Word list = #{@conf[:words]}")
49
- #diaglogger_info(" Option : Hash Seed = #{@conf[:seed]}")
30
+ @cmd_list = [
31
+ "ps -eo pid,ppid,stime,time,%mem,%cpu,cmd",
32
+ "cat /proc/meminfo",
33
+ "netstat -plan",
34
+ "netstat -s",
35
+ ]
50
36
  end
51
37
 
52
38
  def run_precheck()
@@ -130,39 +116,35 @@ module Diagtool
130
116
  end
131
117
  diaglogger_info("[Collect] config file is stored in #{oslog}")
132
118
 
133
- diaglogger_info("[Collect] Collecting process information...")
134
- meminfo = c.collect_ps_eo()
135
- diaglogger_info("[Collect] process informationis stored in #{meminfo}")
136
-
137
- diaglogger_info("[Collect] Collecting OS memory information...")
138
- meminfo = c.collect_meminfo()
139
- diaglogger_info("[Collect] OS memory information is stored in #{meminfo}")
140
-
141
119
  diaglogger_info("[Collect] Collecting date/time information...")
142
120
  if system('which chronyc > /dev/null 2>&1')
143
- ntp = c.collect_ntp(command="chrony")
121
+ ntp = c.collect_cmd_output(command="chronyc sources")
122
+ diaglogger_info("[Collect] date/time information is stored in #{ntp}")
144
123
  elsif system('which ntpq > /dev/null 2>&1')
145
- ntp = c.collect_ntp(command="ntp")
124
+ ntp = c.collect_ntp(command="ntpq -p")
125
+ diaglogger_info("[Collect] date/time information is stored in #{ntp}")
146
126
  else
147
127
  diaglogger_warn("[Collect] chrony/ntp does not exist. skip collectig date/time information")
148
128
  end
149
- diaglogger_info("[Collect] date/time information is stored in #{ntp}")
150
-
151
- diaglogger_info("[Collect] Collecting netstat information...")
152
- if system('which netstat > /dev/null 2>&1')
153
- netstat_n = c.collect_netstat_plan()
154
- netstat_s = c.collect_netstat_s()
155
- if @conf[:mask] == 'yes'
156
- diaglogger_info("[Mask] Masking netstat file : #{netstat_n}...")
157
- netstat_n = m.mask_tdlog(netstat_n, clean = true)
158
- end
159
- diaglogger_info("[Collect] netstat information is stored in #{netstat_n} and #{netstat_s}")
160
- else
161
- diaglogger_warn("[Collect] netstat does not exist. skip collectig netstat")
162
- end
163
129
 
130
+ ###
131
+ # Correct OS information
132
+ ###
133
+ @cmd_list.each { |cmd|
134
+ diaglogger_info("[Collect] Collecting command output : command = #{cmd}")
135
+ out = c.collect_cmd_output(cmd)
136
+ if @conf[:mask] == 'yes'
137
+ diaglogger_info("[Mask] Masking netstat file : #{out}...")
138
+ out = m.mask_tdlog(out, clean = true)
139
+ end
140
+ diaglogger_info("[Collect] Collecting command output #{cmd.split[0]} stored in #{out}")
141
+ }
142
+
143
+ ###
144
+ # Correct information to be validated
145
+ ###
164
146
  diaglogger_info("[Collect] Collecting systctl information...")
165
- sysctl = c.collect_sysctl()
147
+ sysctl = c.collect_cmd_output("sysctl -a")
166
148
  diaglogger_info("[Collect] sysctl information is stored in #{sysctl}")
167
149
 
168
150
  diaglogger_info("[Valid] Validating systctl information...")
@@ -177,7 +159,7 @@ module Diagtool
177
159
  end
178
160
 
179
161
  diaglogger_info("[Collect] Collecting ulimit information...")
180
- ulimit = c.collect_ulimit()
162
+ ulimit = c.collect_cmd_output(cmd="sh -c 'ulimit -n'")
181
163
  diaglogger_info("[Collect] ulimit information is stored in #{ulimit}")
182
164
 
183
165
  diaglogger_info("[Valid] Validating ulimit information...")
@@ -189,9 +171,11 @@ module Diagtool
189
171
  end
190
172
 
191
173
  if @conf[:mask] == 'yes'
192
- diaglogger_info("[Mask] Masking td-agent config file : #{tdconf}...")
193
- m.mask_tdlog(tdconf, clean = true)
194
- tdlog.each do | file |
174
+ tdconf.each { | file |
175
+ diaglogger_info("[Mask] Masking td-agent config file : #{file}...")
176
+ m.mask_tdlog(file, clean = true)
177
+ }
178
+ tdlog.each { | file |
195
179
  diaglogger_info("[Mask] Masking td-agent log file : #{file}...")
196
180
  filename = file.split("/")[-1]
197
181
  if filename.include?(".gz")
@@ -199,14 +183,14 @@ module Diagtool
199
183
  elsif
200
184
  m.mask_tdlog(file, clean = true)
201
185
  end
202
- end
186
+ }
203
187
  end
204
188
 
205
189
  if @conf[:mask] == 'yes'
206
190
  diaglogger_info("[Mask] Export mask log file : #{@masklog}")
207
191
  m.export_masklog(@masklog)
208
192
  end
209
-
193
+
210
194
  tar_file = c.compress_output()
211
195
  diaglogger_info("[Collect] Generate tar file #{tar_file}")
212
196
  end
@@ -33,7 +33,8 @@ module Diagtool
33
33
  :net_ipv4_tcp_max_syn_backlog => "8096",
34
34
  :net_ipv4_tcp_slow_start_after_idle => "0",
35
35
  :net_ipv4_tcp_tw_reuse => "1",
36
- :net_ipv4_ip_local_port_range => ["10240", "65535"]}
36
+ :net_ipv4_ip_local_port_range => ["10240", "65535"]
37
+ }
37
38
  @logger.debug("Initialize Validation Utils:")
38
39
  @logger.debug(" Default ulimit: #{@def_ulimit}")
39
40
  @logger.debug(" Default sysctl: #{@def_sysctl}")
@@ -57,7 +58,7 @@ module Diagtool
57
58
  v = Hash.new { |i,j| i[j] = Hash.new(&h.default_proc) }
58
59
  @logger.info("Loading sysctl file: #{sysctl_file}")
59
60
  File.readlines(sysctl_file).each{ |line|
60
- if line.include?("net")
61
+ if line.include? "net"
61
62
  line_net = line.chomp.gsub(".","_").split("=")
62
63
  key = line_net[0].strip.to_sym
63
64
  if line_net[1].strip! =~ /\s/
@@ -66,17 +67,19 @@ module Diagtool
66
67
  value= line_net[1]
67
68
  end
68
69
  h[key] = value
69
- if @def_sysctl[key] == value
70
- @logger.info("#{key} => #{value} is correct")
71
- v[key]['value'] = value
72
- v[key]['recommend'] = @def_sysctl[key]
73
- v[key]['result'] = "correct"
74
- else
75
- @logger.warn("#{key} => #{value} is incorrect, should be #{@def_sysctl[key]}")
76
- v[key]['value'] = value
77
- v[key]['recommend'] = @def_sysctl[key]
78
- v[key]['result'] = "incorrect"
79
- end
70
+ if @def_sysctl.key? key
71
+ if @def_sysctl[key] == value
72
+ @logger.info("#{key} => #{value} is correct")
73
+ v[key]['value'] = value
74
+ v[key]['recommend'] = @def_sysctl[key]
75
+ v[key]['result'] = "correct"
76
+ else
77
+ @logger.warn("#{key} => #{value} is incorrect, should be #{@def_sysctl[key]}")
78
+ v[key]['value'] = value
79
+ v[key]['recommend'] = @def_sysctl[key]
80
+ v[key]['result'] = "incorrect"
81
+ end
82
+ end
80
83
  end
81
84
  }
82
85
  if h == @sysctl
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module Diagtool
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-diagtool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - kubotat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.1'
40
+ version: '0'
41
41
  description: Bringing productivity of trouble shooting to the next level by automating
42
42
  collection of Fluentd configurations, settings and OS parameters as well as masking
43
43
  sensitive information in logs and configurations.
@@ -56,8 +56,10 @@ files:
56
56
  - README.md
57
57
  - Rakefile
58
58
  - bin/console
59
+ - bin/diagtool.rb
59
60
  - bin/setup
60
61
  - bin/word_list_sample
62
+ - exclude_list01
61
63
  - exe/diagtool
62
64
  - fluent-diagtool.gemspec
63
65
  - lib/fluent/diagtool/collectutils.rb