Class: Honeybadger::Util::Stats Private

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger/util/stats.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

HAS_MEM =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

File.exist?("/proc/meminfo")
HAS_LOAD =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

File.exist?("/proc/loadavg")

Class Method Summary collapse

Class Method Details

.allObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/honeybadger/util/stats.rb', line 8

def all
  { :mem => memory, :load => load }
end

.loadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

From github.com/bloopletech/webstats/blob/master/server/data_providers/cpu_info.rb



23
24
25
26
27
28
29
# 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

.memoryObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

From github.com/bloopletech/webstats/blob/master/server/data_providers/mem_info.rb



13
14
15
16
17
18
19
20
# 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