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/snowman-io/loop/checks_perform.rb', line 6
def self.perform
Check.each do |check|
result = CheckProcessor.new(check).process
send_mail = false
check.last_run_at = DateTime.now
if result
puts "Check for #{check.metric.name} triggered"
unless check.triggered
send_mail = true
end
check.triggered = true
check.last_status = Check::STATUS_FAILED
else
check.last_status = Check::STATUS_OK
end
check.save!
if send_mail
SnowMailer.check_triggered(
check,
check.last_run_at,
Setting.get(SnowmanIO::BASE_URL_KEY),
check.user.email,
true
).deliver_now
check.user.followers.each do |user|
SnowMailer.check_triggered(
check,
check.last_run_at,
Setting.get(SnowmanIO::BASE_URL_KEY),
user.email,
false
).deliver_now
end
end
end
end
|