Class: SystemInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumental_tools/system_inspector.rb,
lib/instrumental_tools/system_inspector/osx.rb,
lib/instrumental_tools/system_inspector/linux.rb

Defined Under Namespace

Modules: Linux, OSX Classes: Memory

Constant Summary collapse

TYPES =
[:gauges, :incrementors]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSystemInspector

Returns a new instance of SystemInspector.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/instrumental_tools/system_inspector.rb', line 9

def initialize
  @gauges = {}
  @incrementors = {}
  @platform =
    case RUBY_PLATFORM
    when /linux/
      require "instrumental_tools/system_inspector/linux"
      SystemInspector::Linux
    when /darwin/
      require "instrumental_tools/system_inspector/osx"
      SystemInspector::OSX
    else
      raise "unsupported OS"
    end
end

Class Method Details

.command_missing(command, section) ⇒ Object



25
26
27
# File 'lib/instrumental_tools/system_inspector.rb', line 25

def self.command_missing(command, section)
  puts "Command #{command} not found. Metrics for #{section} will not be collected."
end

.command_present?(command, section) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/instrumental_tools/system_inspector.rb', line 29

def self.command_present?(command, section)
  `which #{command}`.length > 0 || command_missing(command, section)
end

.memoryObject



5
6
7
# File 'lib/instrumental_tools/system_inspector.rb', line 5

def self.memory
  @memory ||= Memory.new
end

Instance Method Details

#load(stats) ⇒ Object



42
43
44
# File 'lib/instrumental_tools/system_inspector.rb', line 42

def load(stats)
  @gauges.merge!(stats[:gauges] || {})
end

#load_allObject



33
34
35
36
37
38
39
40
# File 'lib/instrumental_tools/system_inspector.rb', line 33

def load_all
  self.class.memory.cycle

  load @platform.load_cpu
  load @platform.load_memory
  load @platform.load_disks
  load @platform.load_filesystem
end