class MonitorManager

Monitor Manager

Public Class Methods

new() click to toggle source
# File lib/monitor_manager.rb, line 3
def initialize
  @list = []
end

Public Instance Methods

add(monitor) click to toggle source
# File lib/monitor_manager.rb, line 7
def add(monitor)
  @list.push monitor
end
run() click to toggle source

The main run loop

# File lib/monitor_manager.rb, line 12
def run
  Kernel.loop do
    @list.each do |m|
      begin
        m.run
      rescue MonitorTypeExceptionHandled => e
        m.alert(e.message)
      end
    end
    sleep 0.2

    exit unless ENV['RUN_ONCE'].nil?
  end

rescue Interrupt
  string = "Exiting on request ...\n"
  puts string

rescue StandardError => e
  puts '*** This is really unexpected.'
  puts e.class.name
  puts "Message: #{e.message}"
  puts e.backtrace
end