class Instrumentation::LoadAverage
Reads loadavg metric from system
Public Class Methods
parse_osx(input)
click to toggle source
Input string looks like:
"{ 1.62 1.59 2.03 }"
@returns
{:one=>"1.62", :five=>"1.59", :ten=>"2.03"}
# 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
Public Instance Methods
read()
click to toggle source
# 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
Private Instance Methods
last_value()
click to toggle source
# File lib/instrumentation/load_average.rb, line 29 def last_value `sysctl -n vm.loadavg` end
system()
click to toggle source
# File lib/instrumentation/load_average.rb, line 25 def system :mac_os end