Class: What::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/what/monitor.rb

Class Method Summary collapse

Class Method Details

.do_it(modules) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/what/monitor.rb', line 14

def self.do_it(modules)
  loop do
    healths = []
    modules.each do |mod|
      mod.check!
      healths << mod.health
      Status[mod.name] = mod.status
    end
    Status['health'] = Helpers.overall_health(healths)
    sleep Config['interval']
  end
end

.go!Object

don’t worry, these method names are ironic



4
5
6
7
8
9
10
11
12
# File 'lib/what/monitor.rb', line 4

def self.go!
  @modules = Config['modules'].map do |m|
    name = Helpers.camelize(m)
    Modules.const_get(name).new
  end

  Thread.abort_on_exception = true
  @thread = Thread.new(@modules) { |modules| self.do_it(modules) }
end