Class: LogStash::Instrument::PeriodicPoller::LoadAverage::Linux

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/instrument/periodic_poller/load_average.rb

Constant Summary collapse

LOAD_AVG_FILE =
"/proc/loadavg"
TOKEN_SEPARATOR =
" "

Class Method Summary collapse

Class Method Details

.get(content = ::File.read(LOAD_AVG_FILE)) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/logstash/instrument/periodic_poller/load_average.rb', line 16

def self.get(content = ::File.read(LOAD_AVG_FILE))
  load_average = content.chomp.split(TOKEN_SEPARATOR)

  {
    :"1m" => load_average[0].to_f,
    :"5m" => load_average[1].to_f,
    :"15m" => load_average[2].to_f
  }
end