Class: Flying::Monitor
- Inherits:
-
Object
- Object
- Flying::Monitor
- Defined in:
- lib/flying/monitor.rb
Instance Method Summary collapse
- #add_bot(bot) ⇒ Object
-
#initialize ⇒ Monitor
constructor
A new instance of Monitor.
-
#perform ⇒ Object
Loops through each bot, making them perform verifications.
Constructor Details
#initialize ⇒ Monitor
Returns a new instance of Monitor.
5 6 7 8 9 10 11 |
# File 'lib/flying/monitor.rb', line 5 def initialize # This is where each bot instance is saved. @bots = [] @an_error_ocurred = false @first_attempt = true @total_attempts = 0 end |
Instance Method Details
#add_bot(bot) ⇒ Object
13 14 15 |
# File 'lib/flying/monitor.rb', line 13 def add_bot(bot) @bots << bot end |
#perform ⇒ Object
Loops through each bot, making them perform verifications
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flying/monitor.rb', line 18 def perform puts "Running..." looping = true while(looping) do @bots.each { |bot| has_error = bot.error assessment = bot.assess if has_error == false && assessment == false @an_error_ocurred = true puts bot. elsif has_error && assessment puts "\e[32m" + bot.referer + " is back online." + "\e[0m" end } if @first_attempt if @an_error_ocurred puts "Some services are down. I'll continue monitoring the targets anyway." else puts "Everything's working fine. I'll continue monitoring the targets." end @first_attempt = false end @total_attempts += 1 sleep(5) end end |