Module: Diagtool::Windows::PlatformSpecificDiagUtils

Included in:
DiagUtils
Defined in:
lib/fluent/diagtool/windows/diagutils.rb

Instance Method Summary collapse

Instance Method Details

#fluent_package?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/fluent/diagtool/windows/diagutils.rb', line 24

def fluent_package?
  ENV.key?("FLUENT_PACKAGE_TOPDIR")
end

#parse_diagconf(params) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fluent/diagtool/windows/diagutils.rb', line 69

def parse_diagconf(params)
  options = {
    :precheck => '', :basedir => '', :type =>'', :mask => '', :words => [], :wfile => '', :seed => '', :tdconf =>'', :tdlog => ''
  }

  supported_options = [:type, :output]

  unless params[:type] == nil || params[:type] == 'fluentd'
    raise "fluentd type '-t' only supports 'fluentd' on Windows."
  end
  options[:type] = 'fluentd'

  if params[:output] != nil
    if Dir.exist?(params[:output])
      options[:basedir] = params[:output]
    else
      raise "output directory '#{params[:output]}' does not exist"
    end
  else
    raise "output directory '-o' must be specified"
  end

  params.keys.each do |option|
    unless supported_options.include?(option)
      raise "#{option} is not supported on Windows."
    end
  end

  return options
end

#run_diagtoolObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fluent/diagtool/windows/diagutils.rb', line 32

def run_diagtool()
  @conf[:time] = @time_format
  @conf[:workdir] = @conf[:basedir] + '/' + @time_format
  @conf[:outdir] = @conf[:workdir] + '/output'
  FileUtils.mkdir_p(@conf[:workdir])
  FileUtils.mkdir_p(@conf[:outdir])
  diaglog = @conf[:workdir] + '/diagtool.output'

  @logger = Logger.new(STDOUT, formatter: proc {|severity, datetime, progname, msg|
    "#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
  })
  @logger_file = Logger.new(diaglog, formatter: proc {|severity, datetime, progname, msg|
    "#{datetime}: [Diagtool] [#{severity}] #{msg}\n"
  })
  diaglogger_info("Parsing command options...")
  diaglogger_info("   Option : Output directory = #{@conf[:basedir]}")

  loglevel = 'WARN'
  diaglogger_info("Initializing parameters...")
  c = CollectUtils.new(@conf, loglevel)

  diaglogger_info("[Collect] Collecting #{@conf[:package_name]} gem information...")
  tdgem = c.collect_tdgems()
  diaglogger_info("[Collect] #{@conf[:package_name]} gem information is stored in #{tdgem}")

  gem_info = c.collect_manually_installed_gems(tdgem)
  diaglogger_info("[Collect] #{@conf[:package_name]} gem information (bundled by default) is stored in #{gem_info[:bundled]}")
  diaglogger_info("[Collect] #{@conf[:package_name]} manually installed gem information is stored in #{gem_info[:local]}")
  local_gems = File.read(gem_info[:local]).lines(chomp: true)
  unless local_gems == [""]
    diaglogger_info("[Collect] #{@conf[:package_name]} manually installed gems:")
    local_gems.each do |gem|
      diaglogger_info("[Collect]   * #{gem}")
    end
  end
end

#run_precheckObject



28
29
30
# File 'lib/fluent/diagtool/windows/diagutils.rb', line 28

def run_precheck()
  raise "[Precheck] Precheck feature is not supported on Windows."
end