Class: Wildcloud::Agent::Heartbeat
- Inherits:
-
Object
- Object
- Wildcloud::Agent::Heartbeat
- Defined in:
- lib/wildcloud/agent/heartbeat.rb
Instance Method Summary collapse
- #heartbeat ⇒ Object
-
#initialize(agent) ⇒ Heartbeat
constructor
A new instance of Heartbeat.
Constructor Details
#initialize(agent) ⇒ Heartbeat
Returns a new instance of Heartbeat.
20 21 22 23 24 25 26 |
# File 'lib/wildcloud/agent/heartbeat.rb', line 20 def initialize(agent) @agent = agent @interval = @agent.config['heartbeat']['interval'] @agent.logger.info('Heartbeat', "Will be reporting every #{@interval} seconds") @timer = EventMachine.add_periodic_timer(@interval, &method(:heartbeat)) @load_monitor = @agent.config['loadmonitor'] && @agent.config['loadmonitor']['active'] end |
Instance Method Details
#heartbeat ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/wildcloud/agent/heartbeat.rb', line 28 def heartbeat = { :components => @agent.component_manager.active_components, :topic => :heartbeat } [:load] = @agent.load_monitor.report if @load_monitor @agent.publish(, :routing_key => 'heartbeat') end |