Sha256: bf27baac37f2e9959cc6350a28d76e563b0a9b64cad35df50849756828331fd2
Contents?: true
Size: 634 Bytes
Versions: 9
Compression:
Stored size: 634 Bytes
Contents
module LitmusPaper module Metric class CPULoad def initialize(weight) @weight = weight end def current_health [@weight - (@weight * load_average / processor_count), 1].max end def processor_count @processor_count ||= File.readlines('/proc/cpuinfo').reduce(0) do |memo, line| if line =~ /^processor/ memo + 1 else memo end end end def load_average File.read('/proc/loadavg').split(' ').first.to_f end def to_s "Metric::CPULoad(#{@weight})" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems