Class: CloudFlock::Interface::CLI::App::Servers::Profile
- Inherits:
-
Object
- Object
- CloudFlock::Interface::CLI::App::Servers::Profile
- Includes:
- Common::Servers, Target::Servers
- Defined in:
- lib/cloudflock/interface/cli/app/servers/profile.rb
Overview
Public: The Profile class provides the interface to produces profiles describing servers running Unix-like operating systems.
Constant Summary collapse
- CLI =
CloudFlock::Interface::CLI::Console
Constants included from Common::Servers
Instance Method Summary collapse
-
#initialize(opts) ⇒ Profile
constructor
Public: Begin Servers migration on the command line.
Methods included from Common::Servers
#define_destination, #define_source, #destination_login, #host_login
Constructor Details
#initialize(opts) ⇒ Profile
Public: Begin Servers migration on the command line
opts - Hash containing options mappings.
14 15 16 17 18 19 20 21 22 23 24 25 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cloudflock/interface/cli/app/servers/profile.rb', line 14 def initialize(opts) resume = opts[:resume] source_host_def = define_source(opts[:config]) source_host_ssh = CLI.spinner("Logging in to #{source_host_def[:host]}") do host_login(source_host_def) end profile = CLI.spinner("Checking source host") do profile = Profile.new(source_host_ssh) profile.build profile end platform = Platform::V2.new(profile[:cpe]) memory = profile[:memory] memory_percent = memory[:mem_used].to_f / memory[:total] * 100 swapping = memory[:swapping?] ftag = "#{CLI.bold}%15s#{CLI.reset}:" hist_mem = profile[:memory_hist][:mem_used] puts puts "#{CLI.bold}System Information#{CLI.reset}" puts "#{ftag} #{platform} (#{profile[:cpe]})" % "OS" puts "#{ftag} #{profile[:arch]}" % "Arch" puts "#{ftag} #{profile[:hostname]}" % "Hostname" puts puts "#{CLI.bold}CPU Statistics#{CLI.reset}" puts "#{ftag} %d" % ["CPU Count", profile[:cpu][:count]] puts "#{ftag} %d MHz" % ["CPU Speed", profile[:cpu][:speed]] puts puts "#{CLI.bold}Memory Statistics#{CLI.reset}" puts "#{ftag} %d MiB" % ["Total RAM", memory[:total]] puts "#{ftag} %d MiB (%2.1f%%)" % ["RAM Used", memory[:mem_used], memory_percent] puts "#{ftag} %d MiB" % ["Swap Used", memory[:swap_used]] if swapping puts "#{ftag} %d%%" % ["Hist. RAM Used", hist_mem] unless hist_mem.nil? puts puts "#{CLI.bold}Hard Disk Statistics#{CLI.reset}" puts "#{ftag} %2.1f GB" % ["Disk Used", profile[:disk]] puts puts "#{CLI.bold}System Statistics#{CLI.reset}" puts "#{ftag} #{profile[:io][:uptime]}" % "Uptime" puts "#{ftag} #{profile[:io][:wait]}" % "I/O Wait" puts puts "#{CLI.bold}IP Information#{CLI.reset}" puts "#{ftag} #{profile[:ip][:public].join(', ')}" % "Public" puts "#{ftag} #{profile[:ip][:private].join(', ')}" % "Private" puts puts "#{CLI.bold}MySQL Databases#{CLI.reset}" puts "#{ftag} #{profile[:db][:count]}" % "Number" puts "#{ftag} #{profile[:db][:size]}" % "Total Size" puts puts "#{CLI.bold}Libraries#{CLI.reset}" puts "#{ftag} #{profile[:lib][:libc]}" % "LIBC" puts "#{ftag} #{profile[:lib][:perl]}" % "Perl" puts "#{ftag} #{profile[:lib][:python]}" % "Python" puts "#{ftag} #{profile[:lib][:ruby]}" % "Ruby" puts "#{ftag} #{profile[:lib][:php]}" % "PHP" unless profile.warnings.empty? puts print CLI.red + CLI.bold profile.warnings.each { |warning| puts warning } print CLI.reset end source_host_ssh.logout! end |