Class: DiagnoseData

Inherits:
Object
  • Object
show all
Defined in:
lib/gaddygaddy-client/diagnose_data.rb

Class Method Summary collapse

Class Method Details

.get_all_diag_infoObject



29
30
31
32
33
34
# File 'lib/gaddygaddy-client/diagnose_data.rb', line 29

def self.get_all_diag_info
  diagnose_data ={}
  diagnose_data['resolvconf'] = get_file_data('/etc/resolv.conf')
  diagnose_data['ifconfig'] = get_cmd_output('ifconfig')
  diagnose_data
end

.get_cmd_output(cmd) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/gaddygaddy-client/diagnose_data.rb', line 49

def self.get_cmd_output(cmd)
  cmd_data = {:cmd => cmd}
  cmd = Mixlib::ShellOut.new(cmd)
  cmd.run_command
  if cmd.error?
    cmd_data[:error] = cmd.stderr
  else
    cmd_data[:result] = cmd.stdout
  end
  cmd_data
end

.get_file_data(file_name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gaddygaddy-client/diagnose_data.rb', line 36

def self.get_file_data(file_name)
  begin
    file_data = {:file_name => file_name}
    data_file = File.open(file_name,'r')
    file_data[:file_content] = data_file.read
    data_file.close
    file_data[:file_time_stamp] = File.mtime(file_name)
  rescue Exception => e
    file_data['error'] = e.inspect
  end
  file_data
end