Class: Dbwatcher::Services::SystemInfo::MachineInfoCollector

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/dbwatcher/services/system_info/machine_info_collector.rb

Overview

Machine information collector service

Collects system-level information about the machine including CPU, memory, disk usage, and process information.

This class is necessarily complex due to the comprehensive machine information it needs to collect across different operating systems. rubocop:disable Metrics/ClassLength

Examples:

info = SystemInfo::MachineInfoCollector.call
puts info[:cpu][:model]
puts info[:memory][:total]
puts info[:disk][:total]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug_enabled?, #log_debug, #log_error, #log_info, #log_warn

Class Method Details

.callHash

Class method to create instance and call

Returns:

  • (Hash)

    machine information



30
31
32
# File 'lib/dbwatcher/services/system_info/machine_info_collector.rb', line 30

def self.call
  new.call
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dbwatcher/services/system_info/machine_info_collector.rb', line 34

def call
  log_info "#{self.class.name}: Collecting machine information"

  {
    hostname: collect_hostname,
    os: collect_os_info,
    cpu: collect_cpu_info,
    memory: collect_memory_info,
    disk: collect_disk_info,
    process: collect_process_info,
    load: collect_load_info,
    uptime: collect_uptime
  }
rescue StandardError => e
  log_error "Machine info collection failed: #{e.message}"
  { error: e.message }
end