@cryptotaxi247 / netdata-1 / commits / 25471a028

final touch for operational pushover.net notifications

Costa Tsaousis (ktsaou) committed Sep 9, 2016 at 02:00 UTC 25471a0285b1f271c19a09fa907e37a464b32f72
3 files changed +39 -42
conf.d/health_alarm_notify.conf
+5 -5
@@ -11,11 +11,11 @@
11
12 # The full path to the sendmail command.
13 # If empty, the system $PATH will be searched for it.
14 -sendmail=
14 +sendmail=""
15
16 # The full path of the curl command.
17 # If empty, the system $PATH will be searched for it.
18 -curl=
18 +curl=""
19
20
21 ###############################################################################
@@ -33,7 +33,7 @@ DEFAULT_RECIPIENT_EMAIL="root"
33
34
35 ###############################################################################
36 -# sending pushover notifications (pushover.com)
36 +# sending pushover notifications (pushover.net)
37
38 # note: multiple recipients can be given like this:
39 # "USERTOKEN1 USERTOKEN2 USERTOKEN3 ..."
@@ -44,11 +44,11 @@ SEND_PUSHOVER="YES"
44 # Login to pushover.com to get your pushover app token
45 # You need only one for all your netdata servers.
46 # Without it, netdata cannot send pushover notifications.
47 -PUSHOVER_APP_TOKEN=
47 +PUSHOVER_APP_TOKEN=""
48
49 # if a role recipient is not configured, a notification will be send to
50 # this pushover user token
51 -DEFAULT_RECIPIENT_PUSHOVER=
51 +DEFAULT_RECIPIENT_PUSHOVER=""
52
53
54 ###############################################################################
plugins.d/alarm-email.sh
+4
@@ -1,2 +1,6 @@
1 +#!/usr/bin/env bash
2 +
3 # OBSOLETE - REPLACED WITH
4 # alarm-notify.sh
5 +
6 +${0/alarm-email.sh/alarm-notify.sh} "${@}"
plugins.d/alarm-notify.sh
+30 -37
@@ -195,11 +195,14 @@ send_email() {
195 # pushover sender
196
197 send_pushover() {
198 - local apptoken="${1}" usertoken="${2}" title="${3}" message="${4}" httpcode sent=0 user
198 + local apptoken="${1}" usertoken="${2}" when="${3}" url="${4}" status="${5}" title="${6}" message="${7}" httpcode sent=0 user priority
199
200 if [ "${SEND_PUSHOVER}" = "YES" -a ! -z "${apptoken}" -a ! -z "${usertoken}" -a ! -z "${title}" -a ! -z "${message}" ]
201 then
202
203 + priority=0
204 + [ "${status}" = "CRITICAL" ] && priority=1
205 +
206 for user in ${usertoken//,/ }
207 do
208 httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
@@ -208,6 +211,10 @@ send_pushover() {
211 --form-string "html=1" \
212 --form-string "title=${title}" \
213 --form-string "message=${message}" \
214 + --form-string "timestamp=${when}" \
215 + --form-string "url=${url}" \
216 + --form-string "url_title=Open netdata dashboard to view the alarm" \
217 + --form-string "priority=${priority}" \
218 https://api.pushover.net/1/messages.json)
219
220 if [ "${httpcode}" == "200" ]
@@ -268,7 +275,7 @@ case "${status}" in
275
276 # don't show the value when the status is CLEAR
277 # for certain alarms, this value might not have any meaning
271 - alarm="${name}"
278 + alarm="${name//_/ }"
279 ;;
280 esac
281
@@ -304,18 +311,15 @@ fi
311 # -----------------------------------------------------------------------------
312 # send the pushover
313
307 -send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${hostname} ${status_message} - ${chart}.${name}" "<font size="5" color=\"${color}\"><b>${hostname} ${status_message}</b></font>
308 -
309 -<b>${alarm}</b>${info}
310 -
311 -Chart: ${chart}
312 -Family: ${family}
313 -Severity: ${severity}
314 -Time: ${date}
315 -${raised_for}
316 -<a href=\"${goto_url}\">View Netdata</a>
317 -
318 -<small>The source of this alarm is line ${src}</small>"
314 +send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${hostname} ${status_message} - ${name//_/ } - ${chart}" "
315 +<font color=\"${color}\"><b>${alarm}</b></font>${info}<br/>&nbsp;
316 +<small><b>${chart}</b><br/>Chart<br/>&nbsp;</small>
317 +<small><b>${family}</b><br/>Family<br/>&nbsp;</small>
318 +<small><b>${severity}</b><br/>Severity<br/>&nbsp;</small>
319 +<small><b>${date}${raised_for}</b><br/>Time<br/>&nbsp;</small>
320 +<a href=\"${goto_url}\">View Netdata</a><br/>&nbsp;
321 +<small><small>The source of this alarm is line ${src}</small></small>
322 +"
323
324 SENT_PUSHOVER=$?
325
@@ -324,7 +328,7 @@ SENT_PUSHOVER=$?
328
329 cat <<EOF | send_email
330 To: ${to_email}
327 -Subject: ${hostname} ${status_message} - ${chart}.${name}
331 +Subject: ${hostname} ${status_message} - ${name//_/ } - ${chart}
332 Content-Type: text/html
333
334 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -336,18 +340,15 @@ Content-Type: text/html
340 <td style="vertical-align:top;" valign="top"></td>
341 <td width="700" style="vertical-align:top;display:block!important;max-width:700px!important;clear:both!important;margin:0 auto;padding:0" valign="top">
342 <div style="max-width:700px;display:block;margin:0 auto;padding:20px">
339 - <table width="100%" cellpadding="0" cellspacing="0"
340 - style="background:#fff;border:1px solid #e9e9e9">
343 + <table width="100%" cellpadding="0" cellspacing="0" style="background:#fff;border:1px solid #e9e9e9">
344 <tbody>
345 <tr>
343 - <td bgcolor="#eee"
344 - style="padding: 5px 20px 5px 20px;background-color:#eee;">
346 + <td bgcolor="#eee" style="padding: 5px 20px 5px 20px;background-color:#eee;">
347 <div style="font-size:20px;color:#777;font-weight: bold;">netdata notification</div>
348 </td>
349 </tr>
350 <tr>
349 - <td bgcolor="${color}"
350 - 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">
351 + <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">
352 <h1 style="font-weight:400;margin:0">${hostname} ${status_message}</h1>
353 </td>
354 </tr>
@@ -357,38 +358,32 @@ Content-Type: text/html
358 <table width="100%" cellpadding="0" cellspacing="0" style="max-width:700px">
359 <tbody>
360 <tr>
360 - <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px"
361 - align="left" valign="top">
361 + <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px" align="left" valign="top">
362 <span>${chart}</span>
363 <span style="display:block;color:#666666;font-size:12px;font-weight:300;line-height:1;text-transform:uppercase">Chart</span>
364 </td>
365 </tr>
366 <tr style="margin:0;padding:0">
367 - <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px"
368 - align="left" valign="top">
367 + <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px" align="left" valign="top">
368 <span><b>${alarm}</b>${info}</span>
369 <span style="display:block;color:#666666;font-size:12px;font-weight:300;line-height:1;text-transform:uppercase">Alarm</span>
370 </td>
371 </tr>
372 <tr>
374 - <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px"
375 - align="left" valign="top">
373 + <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px" align="left" valign="top">
374 <span>${family}</span>
375 <span style="display:block;color:#666666;font-size:12px;font-weight:300;line-height:1;text-transform:uppercase">Family</span>
376 </td>
377 </tr>
378 <tr style="margin:0;padding:0">
381 - <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px"
382 - align="left" valign="top">
379 + <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px" align="left" valign="top">
380 <span>${severity}</span>
381 <span style="display:block;color:#666666;font-size:12px;font-weight:300;line-height:1;text-transform:uppercase">Severity</span>
382 </td>
383 </tr>
384 <tr style="margin:0;padding:0">
388 - <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px"
389 - align="left" valign="top"><span>${date}</span>
390 - <span>${raised_for}</span> <span
391 - style="display:block;color:#666666;font-size:12px;font-weight:300;line-height:1;text-transform:uppercase">Time</span>
385 + <td style="font-size:18px;vertical-align:top;margin:0;padding:0 0 20px" align="left" valign="top"><span>${date}</span>
386 + <span>${raised_for}</span> <span style="display:block;color:#666666;font-size:12px;font-weight:300;line-height:1;text-transform:uppercase">Time</span>
387 </td>
388 </tr>
389 <!--
@@ -399,13 +394,11 @@ Content-Type: text/html
394 </tr>
395 -->
396 <tr style="text-align:center;margin:0;padding:0">
402 - <td style="font-size:11px;vertical-align:top;margin:0;padding:10px 0 0 0;color:#666666"
403 - align="center" valign="bottom">The source of this alarm is line <code>${src}</code>
397 + <td style="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>
398 </td>
399 </tr>
400 <tr style="text-align:center;margin:0;padding:0">
407 - <td style="font-size:12px;vertical-align:top;margin:0;padding:20px 0 0 0;color:#666666;border-top:1px solid #f0f0f0"
408 - align="center" valign="bottom">Sent by
401 + <td style="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
402 <a href="https://mynetdata.io/" target="_blank">netdata</a>, the real-time performance monitoring.
403 </td>
404 </tr>