Class: Instrumentation::LoadAverage

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumentation/load_average.rb

Overview

Reads loadavg metric from system

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_osx(input) ⇒ Object

Input string looks like:

"{ 1.62 1.59 2.03 }"


9
10
11
# File 'lib/instrumentation/load_average.rb', line 9

def parse_osx(input)
  i(one five ten).zip(input.scan(/([0-9\.]+)/).flatten).to_h
end

Instance Method Details

#readObject



14
15
16
17
18
19
20
21
# File 'lib/instrumentation/load_average.rb', line 14

def read
  case system
  when :mac_os
    self.class.parse_osx(last_value)
  else
    raise "Unknown system #{system.inspect}"
  end
end