fluent-diagtool 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,88 @@
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
+
19
+ module Diagtool
20
+ class ValidUtils
21
+ def initialize(log_level)
22
+ @logger = Logger.new(STDOUT, level: log_level, formatter: proc {|severity, datetime, progname, msg|
23
+ "#{datetime}: [Validutils] [#{severity}] #{msg}\n"
24
+ })
25
+ @def_ulimit = "65535".to_i
26
+ @def_sysctl = Hash.new()
27
+ @def_sysctl = { :net_core_somaxconn => "1024",
28
+ :net_core_netdev_max_backlog => "5000",
29
+ :net_core_rmem_max => "16777216",
30
+ :net_core_wmem_max => "16777216",
31
+ :net_ipv4_tcp_wmem => ["4096", "12582912", "16777216"],
32
+ :net_ipv4_tcp_rmem => ["4096", "12582912", "16777216"],
33
+ :net_ipv4_tcp_max_syn_backlog => "8096",
34
+ :net_ipv4_tcp_slow_start_after_idle => "0",
35
+ :net_ipv4_tcp_tw_reuse => "1",
36
+ :net_ipv4_ip_local_port_range => ["10240", "65535"]}
37
+ @logger.debug("Initialize Validation Utils:")
38
+ @logger.debug(" Default ulimit: #{@def_ulimit}")
39
+ @logger.debug(" Default sysctl: #{@def_sysctl}")
40
+ end
41
+ def valid_ulimit(ulimit_file)
42
+ @logger.info("Loading ulimit file: #{ulimit_file}")
43
+ File.readlines(ulimit_file).each { |line|
44
+ if line.chomp.to_i >= @def_ulimit.to_i
45
+ @logger.info(" ulimit => #{line.chomp.to_i} is correct")
46
+ return true, @def_ulimit.to_i, line.chomp.to_i
47
+ else
48
+ @logger.warn(" ulimit => #{line.chomp.to_i} is incorrect, should be #{@def_ulimit}")
49
+ return false, @def_ulimit.to_i, line.chomp.to_i
50
+ end
51
+ }
52
+ end
53
+ def valid_sysctl(sysctl_file)
54
+ h = Hash.new()
55
+ v = Hash.new { |i,j| i[j] = Hash.new(&h.default_proc) }
56
+ @logger.info("Loading sysctl file: #{sysctl_file}")
57
+ File.readlines(sysctl_file).each{ |line|
58
+ if line.include?("net")
59
+ line_net = line.chomp.gsub(".","_").split("=")
60
+ key = line_net[0].strip.to_sym
61
+ if line_net[1].strip! =~ /\s/
62
+ value = line_net[1].split(/\s/)
63
+ else
64
+ value= line_net[1]
65
+ end
66
+ h[key] = value
67
+ if @def_sysctl[key] == value
68
+ @logger.info("#{key} => #{value} is correct")
69
+ v[key]['value'] = value
70
+ v[key]['recommend'] = @def_sysctl[key]
71
+ v[key]['result'] = "correct"
72
+ else
73
+ @logger.warn("#{key} => #{value} is incorrect, should be #{@def_sysctl[key]}")
74
+ v[key]['value'] = value
75
+ v[key]['recommend'] = @def_sysctl[key]
76
+ v[key]['result'] = "incorrect"
77
+ end
78
+ end
79
+ }
80
+ if h == @sysctl
81
+ return true, v
82
+ else
83
+ return false, v
84
+ end
85
+ end
86
+ end
87
+ end
88
+
@@ -0,0 +1,5 @@
1
+ module Fluent
2
+ module Diagtool
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-diagtool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - kubotat
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Bringing productivity of trouble shooting to the next level by automating
14
+ collection of Fluentd configurations, settings and OS parameters as well as masking
15
+ sensitive information in logs and configurations.
16
+ email:
17
+ - tkubota@ctc-america.com
18
+ executables:
19
+ - diagtool
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - AUTHORS
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - bin/console
30
+ - bin/diagtool.rb
31
+ - bin/setup
32
+ - bin/word_list_sample
33
+ - exe/diagtool
34
+ - fluent-diagtool.gemspec
35
+ - lib/fluent/diagtool/collectutils.rb
36
+ - lib/fluent/diagtool/diagutils.rb
37
+ - lib/fluent/diagtool/maskutils.rb
38
+ - lib/fluent/diagtool/validutils.rb
39
+ - lib/fluent/diagtool/version.rb
40
+ homepage: https://github.com/fluent/diagtool/tree/dev
41
+ licenses:
42
+ - Apache-2.0
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.3.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.7.6.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Diagnostic Tool for Fluentd
64
+ test_files: []