Class: Kstats::Node::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/kstats/node/worker.rb

Class Method Summary collapse

Class Method Details

.launch!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
# File 'lib/kstats/node/worker.rb', line 4

def self.launch!
  insert_month = 0
  insert_week = 0
  insert_year = 0

  thread = Thread.new do
    begin
      begin
        puts "***GATHERING INFORMATIONS #{`date`}."
        probes = Kstats::Node::Probe.reload_and_test!

        if insert_month == 0
          insert_month = 30
          Database.save_probes_data(probes, :monthly)
        end

        if insert_week == 0
          insert_week = 7
          Database.save_probes_data(probes, :weekly)
        end

        if insert_year == 0
          insert_year = 365
          Database.save_probes_data(probes, :yearly)
        end

        insert_month  -= 1
        insert_week   -= 1
        insert_year   -= 1

        Database.save_probes_data(probes, :tick)
      rescue Exception => e
        puts e.message
        puts e.backtrace
      end
      sleep(300)
    end while true
  end

end