Sha256: 3961f6225b01e15266f1ab1bf0370c43f2375bcc7131c5bcdb1c8551bd6e18ff

Contents?: true

Size: 910 Bytes

Versions: 26

Compression:

Stored size: 910 Bytes

Contents

module Honeybadger
  class Stats
    HAS_MEM = File.exists?("/proc/meminfo")
    HAS_LOAD = File.exists?("/proc/loadavg")

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

      # From https://github.com/bloopletech/webstats/blob/master/server/data_providers/mem_info.rb
      def memory
        out = {}
        if HAS_MEM
          out[:total], out[:free], out[:buffers], out[:cached] = IO.readlines("/proc/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

      # From https://github.com/bloopletech/webstats/blob/master/server/data_providers/cpu_info.rb
      def load
        out = {}
        out[:one], out[:five], out[:fifteen] = IO.read("/proc/loadavg").split(' ', 4).map(&:to_f) if HAS_LOAD
        out
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
honeybadger-1.16.7 lib/honeybadger/stats.rb
honeybadger-1.16.6 lib/honeybadger/stats.rb
honeybadger-1.16.5 lib/honeybadger/stats.rb
honeybadger-1.16.4 lib/honeybadger/stats.rb
honeybadger-1.16.3 lib/honeybadger/stats.rb
honeybadger-1.16.2 lib/honeybadger/stats.rb
honeybadger-1.16.1 lib/honeybadger/stats.rb
honeybadger-1.16.0 lib/honeybadger/stats.rb
honeybadger-1.15.3 lib/honeybadger/stats.rb
honeybadger-1.15.2 lib/honeybadger/stats.rb
honeybadger-1.15.1 lib/honeybadger/stats.rb
honeybadger-1.15.0 lib/honeybadger/stats.rb
honeybadger-1.14.0 lib/honeybadger/stats.rb
honeybadger-1.13.2 lib/honeybadger/stats.rb
honeybadger-1.13.1 lib/honeybadger/stats.rb
honeybadger-1.13.0 lib/honeybadger/stats.rb
honeybadger-1.12.0.beta3 lib/honeybadger/stats.rb
honeybadger-1.12.0.beta2 lib/honeybadger/stats.rb
honeybadger-1.11.2 lib/honeybadger/stats.rb
honeybadger-1.11.1 lib/honeybadger/stats.rb