Class: Atatus::Metadata::SystemInfo::HWInfo Private

Inherits:
Object
  • Object
show all
Defined in:
lib/atatus/metadata/system_info/hw_info.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHWInfo

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of HWInfo.



13
14
15
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 13

def initialize
  @os = RbConfig::CONFIG['target_os']
end

Instance Attribute Details

#cpuinfo_coresObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 10

def cpuinfo_cores
  @cpuinfo_cores
end

#cpuinfo_mhzObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 10

def cpuinfo_mhz
  @cpuinfo_mhz
end

#cpuinfo_modelObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 10

def cpuinfo_model
  @cpuinfo_model
end

#host_bootidObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 10

def host_bootid
  @host_bootid
end

#meminfo_totalObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 10

def meminfo_total
  @meminfo_total
end

Class Method Details

.read!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 29

def self.read!
  new.read!
end

Instance Method Details

#cpuinfoObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/MethodLength



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 34

def cpuinfo
  @cpuinfo ||=
    begin
      cpuinfo = {
        cores: @cpuinfo_cores,
        model: @cpuinfo_model
      }
      cpuinfo[:mhz] = @cpuinfo_mhz unless @cpuinfo_mhz.nil?

      cpuinfo
    end
end

#hostidObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/MethodLength



53
54
55
56
57
58
59
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 53

def hostid
  @hostid ||=
    begin
      return Socket.gethostname if @host_bootid.nil?
      @host_bootid
    end
end

#meminfoObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:enable Metrics/MethodLength



48
49
50
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 48

def meminfo
  @meminfo ||= @meminfo_total
end

#read!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/atatus/metadata/system_info/hw_info.rb', line 17

def read!
  if @os =~ /(linux)/i
    read_from_cpuinfo!
    read_from_meminfo!
    read_from_bootid!
  elsif @os =~ /(darwin)/i
    read_cpuinfo_from_sysctl!
    read_meminfo_from_sysctl!
  end
  self
end