Class: Wakame::Monitor::Agent
- Inherits:
-
Object
- Object
- Wakame::Monitor::Agent
- Includes:
- Wakame::Monitor
- Defined in:
- lib/wakame/monitor/agent.rb
Constant Summary
Constants included from Wakame::Monitor
STATUS_FAIL, STATUS_OFFLINE, STATUS_ONLINE
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize ⇒ Agent
constructor
A new instance of Agent.
- #send_ping(hash) ⇒ Object
- #setup(path) ⇒ Object
Methods included from Wakame::Monitor
#disable, #enable, #handle_request, included, #publish_to
Constructor Details
#initialize ⇒ Agent
Returns a new instance of Agent.
5 6 7 |
# File 'lib/wakame/monitor/agent.rb', line 5 def initialize @status = STATUS_ONLINE end |
Instance Method Details
#check ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/wakame/monitor/agent.rb', line 25 def check if Wakame.config.environment == :EC2 attrs = Wakame::Agent.ec2_fetch_local_attrs else attrs = {} end res = {:attrs=>attrs, :monitors=>[], :actors=>[], :services=>{}} EM. { agent.monitor_registry.monitors.each { |key, m| res[:monitors] << {:class=>m.class.to_s} } agent.actor_registry.actors.each { |key, a| res[:actors] << {:class=>a.class.to_s} } svcmon = agent.monitor_registry.find_monitor('/service') svcmon.checkers.each { |svc_id, a| res[:services][svc_id]={:status=>a.status} } } res end |
#send_ping(hash) ⇒ Object
9 10 11 |
# File 'lib/wakame/monitor/agent.rb', line 9 def send_ping(hash) publish_to('ping', Wakame::Packets::Ping.new(agent, hash[:attrs], hash[:actors], hash[:monitors], hash[:services]).marshal) end |
#setup(path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wakame/monitor/agent.rb', line 13 def setup(path) # Send the first ping signal as soon as possible since the ping contanins vital information to construct the Agent object on master node. send_ping(check()) # Setup periodical ping publisher. @timer = CheckerTimer.new(10) { send_ping(check()) } @timer.start end |