Class: EzNemo::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/eznemo/monitor.rb

Overview

Maintains an array of all the monitor plugins

Instance Method Summary collapse

Constructor Details

#initializeMonitor

Returns a new instance of Monitor.



12
13
14
# File 'lib/eznemo/monitor.rb', line 12

def initialize
  @plugins = {}
end

Instance Method Details

#register(plugin) ⇒ Object

Registers a plugin; usually called by the plugin itself

Parameters:

  • plugin (Object)


18
19
20
21
# File 'lib/eznemo/monitor.rb', line 18

def register(plugin)
  @plugins[plugin.name] = plugin
  plugin.registered(self)
end

#report(result) ⇒ Object

Report result; usually called by the plugin

Parameters:



37
38
39
# File 'lib/eznemo/monitor.rb', line 37

def report(result)
  EzNemo.datastore.store_result(result)
end

#start_checks(checks) ⇒ Object

Starts check loops in the reactor

Parameters:

  • checks (Array<Hash, ...>)


25
26
27
28
29
30
31
32
33
# File 'lib/eznemo/monitor.rb', line 25

def start_checks(checks)
  i = 0
  checks.each do |c|
    p = @plugins[c[:type].to_sym]
    p.add_check(c)
    i += 1
  end
  EzNemo.logger.info "#{i} checks activated."
end