Module: Host::Linux::LoadAverage

Defined in:
lib/host/linux/load_average.rb

Overview

Implements the recovering of load average information on Linux systems

Constant Summary collapse

RUNNING_PROCESSES =
3
TOTAL_PROCESSES =
4

Instance Method Summary collapse

Instance Method Details

#on_last(minutes) ⇒ Object

Returns the load average in the last minutes. If the parameter passed is neither 1, 5 or 15, then the value returned is the load average on the nearest time.

For instance, Host::LoadAverage.on_last(4) will return the same as Host::LoadAverage.on_last(5).



20
21
22
# File 'lib/host/linux/load_average.rb', line 20

def on_last(minutes)
  @info[nearest(minutes)]
end

#refreshObject

Refreshes your load average information, reading from /proc/loadavg once again



36
37
38
39
# File 'lib/host/linux/load_average.rb', line 36

def refresh
  get_loadinfo(true)
  self
end

#running_processesObject

Returns the number of currently running processes on the system.



25
26
27
# File 'lib/host/linux/load_average.rb', line 25

def running_processes
  @info[RUNNING_PROCESSES]
end

#total_processesObject

Returns total number of processes on the system.



30
31
32
# File 'lib/host/linux/load_average.rb', line 30

def total_processes
  @info[TOTAL_PROCESSES]
end