Class: Wackamole::Mission

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Defined in:
lib/wackamole/models/mission.rb

Class Method Summary collapse

Class Method Details

.pulse(last_tick) ⇒ Object


Pick up moled application pulse



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/wackamole/models/mission.rb', line 9

def self.pulse( last_tick )
  zones = {}
  Wackamole::Control.zones.each do |zone|
    zones[zone] = {}
    Wackamole::Control.mole_databases( zone ).each do |db_name|
      db            = Wackamole::Control.db( zone, db_name )
      app_name, env = Wackamole::Control.extract_app_info( db_name )
      logs_cltn     = db['logs']
      
      zones[zone][app_name] = {} unless zones[zone][app_name]
      zones[zone][app_name][env] = {} unless zones[zone][app_name][env]
      
      zones[zone][app_name][env][:to_date]   = count_logs( logs_cltn )
      zones[zone][app_name][env][:today]     = count_logs( logs_cltn, last_tick, true )
      zones[zone][app_name][env][:last_tick] = count_logs( logs_cltn, last_tick )
    end
  end
  zones
end