Class: Wakame::AgentManagers::MonitorManager

Inherits:
Object
  • Object
show all
Includes:
Wakame::AgentManager
Defined in:
lib/wakame/agent_managers/monitor_manager.rb

Instance Attribute Summary collapse

Attributes included from Wakame::AgentManager

#agent

Instance Method Summary collapse

Methods included from Wakame::AgentManager

#reload, #start, #stop

Constructor Details

#initializeMonitorManager

Returns a new instance of MonitorManager.



18
19
20
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 18

def initialize()
  @monitors = {}
end

Instance Attribute Details

#monitorsObject (readonly)

Returns the value of attribute monitors.



16
17
18
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 16

def monitors
  @monitors
end

Instance Method Details

#find_monitor(path) ⇒ Object



42
43
44
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 42

def find_monitor(path)
  @monitors[path]
end

#initObject



6
7
8
9
10
11
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 6

def init
  agent_mon = register(Monitor::Agent.new, '/agent')
  register(Monitor::Service.new, '/service')
  
  agent_mon.reload({:interval=>10})
end

#register(monitor, path = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 22

def register(monitor, path=nil)
  raise '' unless monitor.kind_of?(Wakame::Monitor)
  
  if path.nil?
    path = '/' + Util.to_const_path(monitor.class.to_s)
  end
  
  if @monitors.has_key?(path)
    Wakame.log.error("#{self.class}: Duplicate registration: #{path}")
    raise "Duplicate registration: #{path}"
  end
  
  monitor.agent = self.agent
  @monitors[path] = monitor
end

#terminateObject



13
14
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 13

def terminate
end

#unregister(path) ⇒ Object



38
39
40
# File 'lib/wakame/agent_managers/monitor_manager.rb', line 38

def unregister(path)
  @monitors.delete(path)
end