class Honeybadger::Util::Stats
Constants
- HAS_LOAD
- HAS_MEM
Public Class Methods
all()
click to toggle source
# File lib/honeybadger/util/stats.rb, line 8 def all { :mem => memory, :load => load } end
load()
click to toggle source
From github.com/bloopletech/webstats/blob/master/server/data_providers/cpu_info.rb
# File lib/honeybadger/util/stats.rb, line 23 def load out = {} if HAS_LOAD && (loadavg = run_loadavg) out[:one], out[:five], out[:fifteen] = loadavg.split(' ', 4).map(&:to_f) end out end
memory()
click to toggle source
From github.com/bloopletech/webstats/blob/master/server/data_providers/mem_info.rb
# File lib/honeybadger/util/stats.rb, line 13 def memory out = {} if HAS_MEM && (meminfo = run_meminfo) out[:total], out[:free], out[:buffers], out[:cached] = meminfo[0..4].map { |l| l =~ /^.*?\: +(.*?) kB$/; ($1.to_i / 1024.0).to_f } out[:free_total] = out[:free] + out[:buffers] + out[:cached] end out end
Private Class Methods
run() { || ... }
click to toggle source
# File lib/honeybadger/util/stats.rb, line 41 def run yield rescue Errno::ENFILE # Catch issues like 'Too many open files in system' nil end
run_loadavg()
click to toggle source
# File lib/honeybadger/util/stats.rb, line 37 def run_loadavg run { IO.read("/proc/loadavg") } end
run_meminfo()
click to toggle source
# File lib/honeybadger/util/stats.rb, line 33 def run_meminfo run { IO.readlines("/proc/meminfo") } end