fluent-diagtool 0.1.5 → 0.1.6

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: 614c1b026136b0743f9c6439b6dd2349adbe9edf3cdb2d77e1ab78698a9d9e49
4
- data.tar.gz: a2228adc3509363ba6bf8f4ddee4d6b1f3feaef2088452a5c69e72057eac2336
3
+ metadata.gz: 459fd1aefd11e12f79ef9f12cd99e289412fc99c3711191508aa3b17af985a6d
4
+ data.tar.gz: 8ed32d7c995ec7a6afb9a618421eb49590f44db96ed10f4babb8440cb3fde271
5
5
  SHA512:
6
- metadata.gz: af815f59c3ed5492175d5fe988eb6eb33fae556b4a2fcd6a20cf89e7e71aa1db92438f7ec1002c08e7f00d59099f91b2d8764f91b18cfb52593c81c5ae89f8e4
7
- data.tar.gz: c7adc36937ba9e1b74a2914a6c2fdf41a6f44dfbd155aa3eb99cf59126022280461a38972eb45f0f486e639b701db6ea7d1c3ec2de73893dd6c982ea9dde8f0c
6
+ metadata.gz: 97adbb75557f1c7c2cf0624e2c9f4aa8ac1631a91d1b30f269fa137223ee20855ceb5764d47cf32f3b01ec0b1e80d541b0ecb069c27d136e456809b935f91efe
7
+ data.tar.gz: e6bc2057366a4f864d7d081235f29bcc0ddbc118412695f52fc6516a642421e9d9770a5a1fd6c7fc2deb7f4cd90a1d3e8d90cb0bcec07e99fd8ef4dc41a90f8a
data/README.md CHANGED
@@ -81,6 +81,14 @@ The following example shows the precheck results when the diagtool is not able t
81
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
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
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
84
92
  The user-defined words can be specified both -e option and -f option and the words are merged when both options are selected.
85
93
  The format of user-defined words list file specified in -f option should be followed format.
86
94
  ```
@@ -90,7 +98,6 @@ centos8102
90
98
  ```
91
99
  NOTE: When user specified the keywork, only the exact match words will be masked. For instance, when users like to mask words like "nginx1" and "nginx2", users need to specify "nginx1" and "nginx2" respectively and "nginx*" should not work in the tool.
92
100
 
93
- ### Run diagtool
94
101
  #### Command sample:
95
102
  ```
96
103
  # diagtool -o /tmp/work1 -w passwd1,passwd2 -f word_list_sample -m yes
@@ -149,7 +156,7 @@ NOTE: When user specified the keywork, only the exact match words will be masked
149
156
  2020-05-12 18:21:22 -0400: [Diagtool] [INFO] [Mask] Export mask log file : ./mask_20200512182119.json
150
157
  2020-05-12 18:21:22 -0400: [Diagtool] [INFO] [Collect] Generate tar file /tmp/work1/diagout-20200512182119.tar.gz
151
158
  ```
152
- ## Mask Function
159
+ #### Mask Function
153
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.
154
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.
155
162
  #### Mask sample - IP address: IPv4_{md5hash}
@@ -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,7 +53,7 @@ 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
59
  @sysctl_path = '/etc/'
@@ -68,7 +68,7 @@ module Diagtool
68
68
  @logger.info(" td-agent log = #{@tdlog}")
69
69
  end
70
70
 
71
- def get_osenv()
71
+ def gen_osenv()
72
72
  stdout, stderr, status = Open3.capture3('hostnamectl')
73
73
  os_dict = {}
74
74
  stdout.each_line { |l|
@@ -83,7 +83,7 @@ module Diagtool
83
83
  return os_dict
84
84
  end
85
85
 
86
- def get_tdenv()
86
+ def gen_tdenv()
87
87
  stdout, stderr, status = Open3.capture3('systemctl cat td-agent')
88
88
  env_dict = {}
89
89
  if status.success?
@@ -143,12 +143,45 @@ module Diagtool
143
143
  target_dir = @workdir+@tdconf_path
144
144
  FileUtils.mkdir_p(target_dir)
145
145
  FileUtils.cp(@tdconf_path+@tdconf, target_dir)
146
- return target_dir+@tdconf
146
+ conf = @workdir+@tdconf_path+@tdconf
147
+ conf_list = []
148
+ conf_list.push target_dir + @tdconf
149
+ File.readlines(conf).each { |line|
150
+ if line.include? '@include'
151
+ f = line.split()[1]
152
+ if f.start_with?(/\//) # /tmp/work1/b.conf
153
+ if f.include?('*')
154
+ Dir.glob(f).each { |ff|
155
+ conf_inc = target_dir + ff.gsub(/\//,'__')
156
+ FileUtils.cp(ff, conf_inc)
157
+ conf_list.push conf_inc
158
+ }
159
+ else
160
+ conf_inc = target_dir+f.gsub(/\//,'__')
161
+ FileUtils.cp(f, conf_inc)
162
+ conf_list.push conf_inc
163
+ end
164
+ else
165
+ f = f.gsub('./','') if f.include?('./')
166
+ if f.include?('*')
167
+ Dir.glob(@tdconf_path+f).each{ |ff|
168
+ conf_inc = target_dir + ff.gsub(@tdconf_path,'').gsub(/\//,'__')
169
+ FileUtils.cp(ff, conf_inc)
170
+ conf_list.push conf_inc
171
+ }
172
+ else
173
+ conf_inc = target_dir+f.gsub(/\//,'__')
174
+ FileUtils.cp(@tdconf_path+f, conf_inc)
175
+ conf_list.push conf_inc
176
+ end
177
+ end
178
+ end
179
+ }
180
+ return conf_list
147
181
  end
148
-
182
+
149
183
  def collect_tdlog()
150
184
  target_dir = @workdir+@tdlog_path
151
- p target_dir
152
185
  FileUtils.mkdir_p(target_dir)
153
186
  Dir.glob(@tdlog_path+@tdlog+'*').each{ |f|
154
187
  FileUtils.cp(f, target_dir)
@@ -189,9 +189,11 @@ module Diagtool
189
189
  end
190
190
 
191
191
  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 |
192
+ tdconf.each { | file |
193
+ diaglogger_info("[Mask] Masking td-agent config file : #{file}...")
194
+ m.mask_tdlog(file, clean = true)
195
+ }
196
+ tdlog.each { | file |
195
197
  diaglogger_info("[Mask] Masking td-agent log file : #{file}...")
196
198
  filename = file.split("/")[-1]
197
199
  if filename.include?(".gz")
@@ -199,7 +201,7 @@ module Diagtool
199
201
  elsif
200
202
  m.mask_tdlog(file, clean = true)
201
203
  end
202
- end
204
+ }
203
205
  end
204
206
 
205
207
  if @conf[:mask] == 'yes'
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module Diagtool
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
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: 0.1.5
4
+ version: 0.1.6
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-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils