servicemonitor 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Alert/Email.rb +10 -5
- data/lib/MonitorManager.rb +2 -2
- data/lib/MonitorType.rb +3 -3
- metadata +2 -2
data/lib/Alert/Email.rb
CHANGED
@@ -4,15 +4,20 @@ require "Alert"
|
|
4
4
|
#Email alert class
|
5
5
|
#Uses localhost for sending email - Probably need to change this in the future.
|
6
6
|
class Alert_Email
|
7
|
-
def initialize( destination, body )
|
8
|
-
@
|
7
|
+
def initialize( sender, destination, body )
|
8
|
+
@sender = sender
|
9
9
|
@body = body
|
10
|
+
|
11
|
+
if destination.is_a? Array then
|
12
|
+
@destination = destination.join( "," )
|
13
|
+
else
|
14
|
+
@destination = destination
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
def Send
|
13
|
-
|
14
19
|
message = <<MESSAGE_END
|
15
|
-
From: #{ENV['APP_NAME']}
|
20
|
+
From: #{ENV['APP_NAME']} #{@sender}
|
16
21
|
To: #{@destination}
|
17
22
|
Subject: #{ENV['APP_NAME']} Alert
|
18
23
|
|
@@ -21,7 +26,7 @@ Subject: #{ENV['APP_NAME']} Alert
|
|
21
26
|
MESSAGE_END
|
22
27
|
|
23
28
|
Net::SMTP.start('localhost') do |smtp|
|
24
|
-
smtp.send_message message,
|
29
|
+
smtp.send_message message, @sender,
|
25
30
|
@destination
|
26
31
|
end
|
27
32
|
|
data/lib/MonitorManager.rb
CHANGED
data/lib/MonitorType.rb
CHANGED
@@ -36,10 +36,10 @@ class MonitorType
|
|
36
36
|
puts "*** EMAIL_SENDER=<email of sender>"
|
37
37
|
abort
|
38
38
|
else
|
39
|
-
@
|
39
|
+
@sender_email = ENV["EMAIL_SENDER"]
|
40
40
|
end
|
41
41
|
else
|
42
|
-
@
|
42
|
+
@sender_email = params[:admin_email]
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -83,7 +83,7 @@ class MonitorType
|
|
83
83
|
body = "#{@name} tripped.\n#{string}"
|
84
84
|
puts "*** "
|
85
85
|
if !@email.nil? then
|
86
|
-
Alert_Email.new( @email, body ).Send
|
86
|
+
Alert_Email.new( @sender_email, @email, body ).Send
|
87
87
|
puts "Emailed, #{@email}"
|
88
88
|
else
|
89
89
|
puts body
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servicemonitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Monitor various parts of the system
|
15
15
|
email: guy@guyirvine.com
|