Class: Wary::Check::LoadAverage

Inherits:
Object
  • Object
show all
Includes:
Wary::Check
Defined in:
lib/wary/check/load_average.rb

Instance Attribute Summary

Attributes included from Wary::Check

#name

Instance Method Summary collapse

Methods included from Wary::Check

#configure

Constructor Details

#initialize(options) ⇒ LoadAverage

Returns a new instance of LoadAverage.



10
11
12
13
14
# File 'lib/wary/check/load_average.rb', line 10

def initialize(options)
  @load_meter = options.fetch(:load_meter) { Wary::LoadMeter.new }
  @alert_threshold = options.fetch(:alert_threshold)
  configure(options)
end

Instance Method Details

#statusObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wary/check/load_average.rb', line 16

def status
  begin
    load = @load_meter.load
  rescue => e
    return failure(e.message)
  end

  if load < @alert_threshold
    ok("Load #{load}")
  else
    alert("Load #{load} exceeds threshold (#{@alert_threshold})")
  end
end