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,
lib/instrumental_tools/system_inspector/win32.rb

Defined Under Namespace

Modules: Linux, OSX, Win32 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
24
25
26
# 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
    when /(windows|win32|mingw)/
      require "instrumental_tools/system_inspector/win32"
      SystemInspector::Win32
    else
      raise "unsupported OS"
    end
end

Class Method Details

.command_missing(command, section) ⇒ Object



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

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)


32
33
34
# File 'lib/instrumental_tools/system_inspector.rb', line 32

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



45
46
47
# File 'lib/instrumental_tools/system_inspector.rb', line 45

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

#load_allObject



36
37
38
39
40
41
42
43
# File 'lib/instrumental_tools/system_inspector.rb', line 36

def load_all
  self.class.memory.cycle

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