Class: Wildcloud::Agent::Heartbeat

Inherits:
Object
  • Object
show all
Defined in:
lib/wildcloud/agent/heartbeat.rb

Instance Method Summary collapse

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

#heartbeatObject



28
29
30
31
32
33
34
35
# File 'lib/wildcloud/agent/heartbeat.rb', line 28

def heartbeat
  message = {
      :components => @agent.component_manager.active_components,
      :topic => :heartbeat
  }
  message[:load] = @agent.load_monitor.report if @load_monitor
  @agent.publish(message, :routing_key => 'heartbeat')
end