aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbytemark_example_alerts.sh6
-rw-r--r--lib/mauve/notifiers/email.rb17
-rw-r--r--lib/mauve/notifiers/templates/email.html.erb22
-rw-r--r--lib/mauve/notifiers/templates/email.txt.erb2
4 files changed, 27 insertions, 20 deletions
diff --git a/bytemark_example_alerts.sh b/bytemark_example_alerts.sh
index 916ffb5..1d4041c 100755
--- a/bytemark_example_alerts.sh
+++ b/bytemark_example_alerts.sh
@@ -22,12 +22,12 @@ $PRE -o networkmonitor -i 2 -u cr01.thn.bytemark.co.uk \
-s "cr02.man.bytemark.co.uk refused SSH connection" \
-d "<pre>ssh: connect to host localhost port 1212: Connection refused</pre>"
-$PRE -o ventham.bytemark.co.uk -i heartbeat -r now -s "<b>heartbeat</b> <script>alert('arse')</script> failed for ventham.bytemark.co.uk" --detail="<p>The heartbeat wasn't sent for the host ventham.bytemark.co.uk</p><p>This indicates that the host might be down</p>" >/dev/null
+$PRE -o ventham.bytemark.co.uk -i heartbeat -r +10m -c now -s "<b>heartbeat</b> <script>alert('arse')</script> failed for ventham.bytemark.co.uk" --detail="<p>The heartbeat wasn't sent for the host ventham.bytemark.co.uk</p><p>This indicates that the host might be down</p>" >/dev/null
-$PRE -o networkmonitor -i ping-ventham -u ventham.bytemark.co.uk -r +10m -s "ping failed for ventham.bytemark.co.uk"
+$PRE -o networkmonitor -i ping-ventham -u ventham.bytemark.co.uk -r -s "ping failed for ventham.bytemark.co.uk"
$PRE -o vmhs -i 12345 -u partridge.bytemark.co.uk \
- -s "partridge.bytemark.co.uk heartbeat not received" -r +10m -c now
+ -s "partridge.bytemark.co.uk heartbeat not received" -r +10m -c
$PRE -o vmhs -i 12347 -u eider.bytemark.co.uk \
-s "eider.bytemark.co.uk heartbeat not received" -r +2
diff --git a/lib/mauve/notifiers/email.rb b/lib/mauve/notifiers/email.rb
index 168a9d6..75588f4 100644
--- a/lib/mauve/notifiers/email.rb
+++ b/lib/mauve/notifiers/email.rb
@@ -67,8 +67,21 @@ module Mauve
end
m = RMail::Message.new
-
- m.header.subject = "Arse"
+
+ #
+ # Use a template for:
+ #
+ # * The subject
+ # * The text part
+ # * The HTML part.
+ #
+ subject_template = File.join(File.dirname(__FILE__), "templates", "email_subject.txt.erb")
+ if File.exists?(subject_template)
+ m.header.subject = ERB.new(File.read(subject_template)).result(binding).chomp
+ else
+ m.header.subject = "Arse"
+ end
+
m.header.to = destination
m.header.from = @from
m.header.date = MauveTime.now
diff --git a/lib/mauve/notifiers/templates/email.html.erb b/lib/mauve/notifiers/templates/email.html.erb
index fcf0620..c568d77 100644
--- a/lib/mauve/notifiers/templates/email.html.erb
+++ b/lib/mauve/notifiers/templates/email.html.erb
@@ -1,4 +1,7 @@
-<p><strong><%= alert.update_type.upcase %></strong> <%
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body>
+<p><strong><%= alert.update_type.upcase %>:</strong> <%
case alert.update_type
when :cleared
%><%= MauveTime.now.to_s_relative(alert.cleared_at.to_time) %><%
@@ -11,18 +14,9 @@ end
if alert.source != alert.subject
%> -- <em>from <%= alert.source %></em><%
end
-%>.
-
+%>.</p>
<hr />
-
-<div>
-<%=alert.detail %>
-</div>
-
+<h2>Detail</h2>
+<div><%=alert.detail %></div>
<hr />
-
-<address>
---<br />
-Love mauve<br />
-xxx.
-</address>
+<address>--<br />Love mauve<br />xxx.</address></body></html>
diff --git a/lib/mauve/notifiers/templates/email.txt.erb b/lib/mauve/notifiers/templates/email.txt.erb
index 8f7e9a4..eb49da9 100644
--- a/lib/mauve/notifiers/templates/email.txt.erb
+++ b/lib/mauve/notifiers/templates/email.txt.erb
@@ -13,7 +13,7 @@ if alert.source != alert.subject
end
%>.
--- Details ------------------------------------------------------------
+-- Detail ------------------------------------------------------------
<%= Sanitize.clean(alert.detail) %>