Class: PerfMonger::Command::FingerprintCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- PerfMonger::Command::FingerprintCommand
- Defined in:
- lib/perfmonger/command/fingerprint.rb
Instance Method Summary collapse
-
#initialize ⇒ FingerprintCommand
constructor
A new instance of FingerprintCommand.
- #parse_args(argv) ⇒ Object
- #run(argv) ⇒ Object
Methods inherited from BaseCommand
register_alias, register_command
Constructor Details
#initialize ⇒ FingerprintCommand
Returns a new instance of FingerprintCommand.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/perfmonger/command/fingerprint.rb', line 14 def initialize @parser = OptionParser.new @parser. = "Usage: perfmonger fingerprint [options] OUTPUT_TARBALL\n\nOptions:\n" hostname = `hostname`.strip @output_tarball = "./fingerprint.#{hostname}.tar.gz" end |
Instance Method Details
#parse_args(argv) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/perfmonger/command/fingerprint.rb', line 26 def parse_args(argv) @parser.parse!(argv) if argv.size == 0 puts("ERROR: output directory is required.") puts(@parser.help) exit(false) end @output_tarball = argv.shift if ! @output_tarball =~ /\.(tar\.gz|tgz)$/ @output_tarball += ".tar.gz" end end |
#run(argv) ⇒ Object
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/perfmonger/command/fingerprint.rb', line 42 def run(argv) parse_args(argv) ENV['LANG'] = 'C' $stderr.puts("System information is gathered into #{@output_tarball}") Dir.mktmpdir do |tmpdir| output_basename = File.basename(@output_tarball.gsub(/\.(tar\.gz|tgz)$/, '')) @output_dir = File.join(tmpdir, output_basename) FileUtils.mkdir(@output_dir) ## Collect generic info. ("Saving /proc info") do save_proc_info() end ("Saving numactl info") do save_numactl_info() end ("Saving IRQ info") do save_irq_info() end ("Saving block device info") do save_device_info() end ("Saving /dev/disk info") do save_disk_info() end ("Saving fdisk info") do save_fdisk_info() end ("Saving lsblk info") do save_lsblk_info() end ("Saving LVM info") do save_lvm_info() end ("Saving PCI/PCIe info") do save_pci_info() end ("Saving kernel module info") do save_module_info() end ("Saving distro info") do save_distro_info() end ("Saving sysctl info") do save_sysctl_info() end ("Saving dmidecode info") do save_dmidecode_info() end ("Saving biosdecode info") do save_biosdecode_info() end ("Saving nvme info") do save_nvme_info() end ## Collect vendor specific info # https://aws.amazon.com/jp/code/ec2-instance-metadata-query-tool/ if find_executable("ec2-metadata") ("Saving EC2 metadata info") do () end end # LSI MegaRAID megacli_bin = "/opt/MegaRAID/MegaCli/MegaCli64" if File.executable?(megacli_bin) && Process::UID.rid == 0 ("Saving MegaRAID settings") do save_megaraid_info(megacli_bin) end end tmptar_path = Tempfile.new("fingerprint").path Dir.chdir(tmpdir) do if ! system("tar czf '#{tmptar_path}' #{output_basename}") raise RuntimeError.new("Failed to execute tar(1)") end end FileUtils.mv(tmptar_path, @output_tarball) end true end |