Class: SrvMonitor::Scouts::LoadAverage

Inherits:
SrvMonitor::Scout show all
Extended by:
Expectations::LoadAverage
Defined in:
lib/srvmonitor/scouts/load_average.rb

Constant Summary

Constants included from Expectations::LoadAverage

Expectations::LoadAverage::LOAD_AVERAGE_MAPPING

Instance Attribute Summary collapse

Attributes inherited from SrvMonitor::Scout

#server, #status

Instance Method Summary collapse

Methods included from Expectations::LoadAverage

evaluate_load_average, extended

Methods inherited from SrvMonitor::Scout

expect, expectations, #local?, #options, #remote?, #run

Constructor Details

#initialize(options) ⇒ LoadAverage

Configure the scout with given options.

Parameters:

  • Options (Hash)

    to setup the scout



12
13
14
# File 'lib/srvmonitor/scouts/load_average.rb', line 12

def initialize(options)
  @server = options[:server]
end

Instance Attribute Details

#load_averageObject (readonly)

Returns the value of attribute load_average.



8
9
10
# File 'lib/srvmonitor/scouts/load_average.rb', line 8

def load_average
  @load_average
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
# File 'lib/srvmonitor/scouts/load_average.rb', line 16

def execute
  case
  when remote? then remote_exec
  when local?  then local_exec
  end
rescue
  @load_average = nil
end

#outputObject



25
26
27
28
29
# File 'lib/srvmonitor/scouts/load_average.rb', line 25

def output
  st = "#{@status}\tload: #{@load_average}"
  st = "[#{@server.name}]\t#{st}"
  st
end