Sha256: 382a8c6310e64e86857ccdf4a085c8b0940d63b16aea3fc7894fbe4dd189af05
Contents?: true
Size: 960 Bytes
Versions: 1
Compression:
Stored size: 960 Bytes
Contents
require "ffi" require "rapporteur" module Rapporteur module Checks class LoadCheck extend FFI::Library ffi_lib FFI::Library::LIBC attach_function :getloadavg, [:pointer, :int], :int attach_function :strerror, [:int], :string private_class_method :getloadavg, :strerror DEFAULT_TOLERANCE = 8.0 def initialize(tolerance=DEFAULT_TOLERANCE) @tolerance = tolerance end def call(checker) loadavg = self.class.current_load checker.add_error(:excess_load) if loadavg > @tolerance checker.add_message(:load, loadavg) end def self.call(checker) new.call(checker) end def self.current_load loadavg = FFI::MemoryPointer.new(:double, 1) if getloadavg(loadavg, 1) == -1 raise SystemCallError, "getloadavg() - #{strerror(FFI.errno)}" end loadavg.read_double end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rapporteur-load_check-1.1.0 | lib/rapporteur/load_check.rb |