module DockDriver::Template::Linux

Adds network-related methods to the DockDriver::Template DSL.

Since I’m using a bit of metaprogramming, here’s a list of DSL methods that this module brings to the template:

loadavg_one

1 minute load average

loadavg_five

minute load average

loadavg_fifteen

15 minute load average

loadavg_running

otal number of running processes

loadavg_total

total number of processes

loadavg_last_pid

last running process id

Example:

<%= loadavg_one %> => 1.61

Constants

LOADAVG_KEYS

Map of column names for the load stats.

LOADAVG_PATH

Path to load stats. (procfs)

Private Instance Methods

loadavg() click to toggle source

Parse the contents of LOADAVG_PATH and return a hash of values found.

# File lib/dock_driver/template/linux.rb, line 52
def loadavg
    loadavg = File.read( LOADAVG_PATH ).strip
    items = loadavg.split( ' ' )
    items[3] = items[3].split('/')
    items.flatten!
    return Hash[LOADAVG_KEYS.zip( items )]
rescue Exception
    return Hash.new
end