Class: Wakame::AgentManagers::MonitorManager
- Inherits:
-
Object
- Object
- Wakame::AgentManagers::MonitorManager
- Includes:
- Wakame::AgentManager
- Defined in:
- lib/wakame/agent_managers/monitor_manager.rb
Instance Attribute Summary collapse
-
#monitors ⇒ Object
readonly
Returns the value of attribute monitors.
Attributes included from Wakame::AgentManager
Instance Method Summary collapse
- #find_monitor(path) ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ MonitorManager
constructor
A new instance of MonitorManager.
- #register(monitor, path = nil) ⇒ Object
- #terminate ⇒ Object
- #unregister(path) ⇒ Object
Methods included from Wakame::AgentManager
Constructor Details
#initialize ⇒ MonitorManager
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
#monitors ⇒ Object (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 |
#init ⇒ Object
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 |
#terminate ⇒ Object
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 |