Class: Scout::Command::Troubleshoot

Inherits:
Scout::Command show all
Defined in:
lib/es-scout/command/troubleshoot.rb

Constant Summary

Constants inherited from Scout::Command

HTTP_HEADERS

Instance Attribute Summary

Attributes inherited from Scout::Command

#config_dir, #history, #log_path, #server

Instance Method Summary collapse

Methods inherited from Scout::Command

#create_pid_file_or_exit, dispatch, #level, #log, #program_name, program_name, program_path, #program_path, usage, #usage, #user, user, #verbose?

Constructor Details

#initialize(options, args) ⇒ Troubleshoot

Returns a new instance of Troubleshoot.



18
19
20
21
22
23
24
# File 'lib/es-scout/command/troubleshoot.rb', line 18

def initialize(options, args)
  @post = options[:troubleshoot_post]
  @include_history = !options[:troubleshoot_no_history]
  @contents=[]
  options[:verbose]=true # force verbose logging for this command
  super
end

Instance Method Details

#runObject



26
27
28
29
30
31
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
68
69
70
71
72
73
# File 'lib/es-scout/command/troubleshoot.rb', line 26

def run
  puts "Gathering troubleshooting information about your Scout install ... "

  heading "Scout Info"
  bullet "History file", history
  bullet "Version", Scout::VERSION

  heading "Latest Log"
  contents=File.read(log_path) rescue "Log not found at #{log_path}"
  text contents

  heading "Rubygems Environment"
  text `gem env`

  heading "Ruby info"
  bullet "Path to executable", `which ruby`
  bullet "Version", `ruby -v`
  bullet "Ruby's internal path",  $:.join(', ')

  heading "Installed Gems"
  text `gem list --local`


  if @include_history
    heading "History file Contents"
    contents=File.read(history) rescue "History not found at #{log_path}"
    text contents
  else
    heading "Skipping History file Contents"
  end

  heading "Agent directory Contents"
  text `ls -la #{config_dir}`

  heading ""

  if @post
    puts "Posting troubleshooting info to #{@server} ... "
    url = URI.join( @server,"/admin/troubleshooting_reports")
    post_form(url, "Couldn't contact server at #{@server}",{:body=>contents_as_text}) do |res|
      puts "Scout server says: \"#{res.body}\""
    end
  else
    puts contents_as_text
  end

  puts " ... Done"
end