@cryptotaxi247 / netdata-1 / commits / 632e6c0f1

MIME encoded / multipart / text and html email notifications; #2203

Costa Tsaousis (ktsaou) committed May 20, 2017 at 03:32 UTC 632e6c0f102250e4057c4d752acbde47ef911400
1 file changed +37 -14
plugins.d/alarm-notify.sh
+37 -14
@@ -143,7 +143,8 @@ old_value_string="${20}" # friendly old value (with units)
143 # -----------------------------------------------------------------------------
144 # find a suitable hostname to use, if netdata did not supply a hostname
145
146 -[ -z "${host}" ] && host="$(hostname 2>/dev/null)"
146 +this_host=$(hostname -s 2>/dev/null)
147 +[ -z "${host}" ] && host="${this_host}"
148
149 # -----------------------------------------------------------------------------
150 # screen statuses we don't need to send a notification
@@ -1304,11 +1305,33 @@ SENT_HIPCHAT=$?
1305 send_email <<EOF
1306 To: ${to_email}
1307 Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
1308 +MIME-Version: 1.0
1309 +Content-Type: multipart/alternative; boundary="multipart-boundary"
1310 +
1311 +This is a MIME-encoded multipart message
1312 +
1313 +--multipart-boundary
1314 +Content-Type: text/plain
1315 +
1316 +${host} ${status_message}
1317 +
1318 +${alarm} ${info}
1319 +${raised_for}
1320 +
1321 +Chart : ${chart}
1322 +Family : ${family}
1323 +Severity: ${severity}
1324 +URL : ${goto_url}
1325 +Source : ${src}
1326 +Date : ${date}
1327 +Notification generated on ${this_host}
1328 +
1329 +--multipart-boundary
1330 Content-Type: text/html
1331
1332 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1310 -<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0; padding: 0;">
1311 -<body style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 14px; width: 100% !important; min-height: 100%; line-height: 1.6; background: #f6f6f6; margin:0; padding: 0;">
1333 +<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0; padding: 0;">
1334 +<body style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; width: 100% !important; min-height: 100%; line-height: 1.6; background: #f6f6f6; margin:0; padding: 0;">
1335 <table>
1336 <tbody>
1337 <tr>
@@ -1319,12 +1342,12 @@ Content-Type: text/html
1342 <tbody>
1343 <tr>
1344 <td bgcolor="#eee" style="padding: 5px 20px 5px 20px; background-color: #eee;">
1322 - <div style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 20px; color: #777; font-weight: bold;">netdata notification</div>
1345 + <div style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 20px; color: #777; font-weight: bold;">netdata notification</div>
1346 </td>
1347 </tr>
1348 <tr>
1349 <td bgcolor="${color}" style="font-size: 16px; vertical-align: top; font-weight: 400; text-align: center; margin: 0; padding: 10px; color: #ffffff; background: ${color} !important; border: 1px solid ${color}; border-top-color: ${color};" align="center" valign="top">
1327 - <h1 style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: 400; margin: 0;">${host} ${status_message}</h1>
1350 + <h1 style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 400; margin: 0;">${host} ${status_message}</h1>
1351 </td>
1352 </tr>
1353 <tr>
@@ -1333,46 +1356,46 @@ Content-Type: text/html
1356 <table width="100%" cellpadding="0" cellspacing="0" style="max-width:700px">
1357 <tbody>
1358 <tr>
1336 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding:0 0 20px;" align="left" valign="top">
1359 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding:0 0 20px;" align="left" valign="top">
1360 <span>${chart}</span>
1361 <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Chart</span>
1362 </td>
1363 </tr>
1364 <tr style="margin: 0; padding: 0;">
1342 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
1365 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
1366 <span><b>${alarm}</b>${info_html}</span>
1367 <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Alarm</span>
1368 </td>
1369 </tr>
1370 <tr>
1348 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
1371 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
1372 <span>${family}</span>
1373 <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Family</span>
1374 </td>
1375 </tr>
1376 <tr style="margin: 0; padding: 0;">
1354 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
1377 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top">
1378 <span>${severity}</span>
1379 <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Severity</span>
1380 </td>
1381 </tr>
1382 <tr style="margin: 0; padding: 0;">
1360 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top"><span>${date}</span>
1383 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;" align="left" valign="top"><span>${date}</span>
1384 <span>${raised_for_html}</span> <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Time</span>
1385 </td>
1386 </tr>
1387 <tr style="margin: 0; padding: 0;">
1365 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;">
1388 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;">
1389 <a href="${goto_url}" style="font-size: 14px; color: #ffffff; text-decoration: none; line-height: 1.5; font-weight: bold; text-align: center; display: inline-block; text-transform: capitalize; background: #35568d; border-width: 1px; border-style: solid; border-color: #2b4c86; margin: 0; padding: 10px 15px;" target="_blank">View Netdata</a>
1390 </td>
1391 </tr>
1392 <tr style="text-align: center; margin: 0; padding: 0;">
1370 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 11px; vertical-align: top; margin: 0; padding: 10px 0 0 0; color: #666666;" align="center" valign="bottom">The source of this alarm is line <code>${src}</code>
1393 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11px; vertical-align: top; margin: 0; padding: 10px 0 0 0; color: #666666;" align="center" valign="bottom">The source of this alarm is line <code>${src}</code><br/>(alarms are configurable, edit this file to adapt the alarm to your needs)
1394 </td>
1395 </tr>
1396 <tr style="text-align: center; margin: 0; padding: 0;">
1374 - <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 12px; vertical-align: top; margin:0; padding: 20px 0 0 0; color: #666666; border-top: 1px solid #f0f0f0;" align="center" valign="bottom">Sent by
1375 - <a href="https://mynetdata.io/" target="_blank">netdata</a>, the real-time performance monitoring.
1397 + <td style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; vertical-align: top; margin:0; padding: 20px 0 0 0; color: #666666; border-top: 1px solid #f0f0f0;" align="center" valign="bottom">Sent by
1398 + <a href="https://mynetdata.io/" target="_blank">netdata</a>, the real-time performance and health monitoring, on <code>${this_host}</code>.
1399 </td>
1400 </tr>
1401 </tbody>