This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
/
mailto-service.erb
67 lines (53 loc) · 1.97 KB
/
mailto-service.erb
1
2
3
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<%
require 'erb'
require 'uri'
# We could use Mail.random_tag for this instead of a static string.
boundary = "00112233445566778899AABBCCDD"
state_time = Time.at(LASTSERVICESTATECHANGE.to_i)
# LONGSERVICEOUTPUT has escaped newlines, so fix those.
output = [SERVICEOUTPUT, LONGSERVICEOUTPUT.split("\\n")].flatten.join("\n")
%>
To: <%= recipient.user %>
Subject: <%= NOTIFICATIONTYPE %>: <%= SERVICEDESC %> is <%= SERVICESTATE %> on <%= HOSTALIAS %> (id: <%= LASTSERVICESTATECHANGE %>)
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=<%= boundary %>
--<%= boundary %>
Content-Type: text/plain; charset=utf-8
Date/Time: <%= LONGDATETIME %>
Notification Type: <%= NOTIFICATIONTYPE %>
Service: <%= SERVICEDESC %>
Host: <%= HOSTALIAS %> / <%= HOSTADDRESS %>
State: <%= SERVICESTATE %>
Attempt: <%= SERVICEATTEMPT %> of <%= MAXSERVICEATTEMPTS %>
Age in <%= SERVICESTATE %>: <%= Time.now - state_time %> seconds (since <%= state_time %>)
Check output:
<%= output %>
--<%= boundary %>
Content-Type: text/html; charset=utf-8
<h3> Nagios Message </h3>
<b>Date/Time: </b> <%= LONGDATETIME %> <br>
<b>Host: </b> <%= HOSTALIAS %> / <%= HOSTADDRESS %> <br>
<b>Service Check: </b> <%= SERVICEDESC %> <br>
<b>Notification Type: </b> <%= NOTIFICATIONTYPE %> <br>
<b>State: </b> <%= SERVICESTATE %> <br>
<b>Attempt: </b> <%= SERVICEATTEMPT %> of <%= MAXSERVICEATTEMPTS %> <br>
<b>Age in <%= SERVICESTATE %>: </b> <%= Time.now - state_time %> seconds (since <%= state_time %>)
<h3> Actions </h3>
<% summary = "Service Alert: " + URI.escape(SERVICEDESC) %>
<% description = URI.escape("
* Date/Time: #{LONGDATETIME}
* Notification Type: #{NOTIFICATIONTYPE}
* State: #{SERVICESTATE}
* Service: #{SERVICEDESC}
* Host: #{HOSTALIAS} / #{HOSTADDRESS}
Check output:
{noformat}
#{output}
{noformat}
")
%>
<h3> Check Output </h3>
<pre style="border: 1px solid black; background-color: #E3ECED; padding: 1em; margin: 1em;">
<%= ERB::Util::h(output) %>
</pre>
--<%= boundary %>--