]> arthur.barton.de Git - netdata.git/blob - plugins.d/alarm-notify.sh
fixed a bug that prevented dispatching alarms to multiple email recipients
[netdata.git] / plugins.d / alarm-notify.sh
1 #!/usr/bin/env bash
2
3 # (C) Costa Tsaousis
4 # pushover support by Jan Arnold
5
6 me="${0}"
7
8 if [ $(( ${BASH_VERSINFO[0]} )) -lt 4 ]
9 then
10     echo >&2
11     echo >&2 "$me: ERROR"
12     echo >&2 "BASH version 4 or later is required."
13     echo >&2 "You are running version: ${BASH_VERSION}"
14     echo >&2 "Please upgrade."
15     echo >&2
16     exit 1
17 fi
18
19 # -----------------------------------------------------------------------------
20 # parse command line parameters
21
22 recipient="${1}"   # the recepient of the email
23 host="${2}"        # the host this event refers to
24 unique_id="${3}"   # the unique id of this event
25 alarm_id="${4}"    # the unique id of the alarm that generated this event
26 event_id="${5}"    # the incremental id of the event, for this alarm
27 when="${6}"        # the timestamp this event occured
28 name="${7}"        # the name of the alarm, as given in netdata health.d entries
29 chart="${8}"       # the name of the chart (type.id)
30 family="${9}"      # the family of the chart
31 status="${10}"     # the current status : REMOVED, UNITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
32 old_status="${11}" # the previous status: REMOVED, UNITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
33 value="${12}"      # the current value
34 old_value="${13}"  # the previous value
35 src="${14}"        # the line number and file the alarm has been configured
36 duration="${15}"   # the duration in seconds the previous state took
37 non_clear_duration="${16}" # the total duration in seconds this is non-clear
38 units="${17}"      # the units of the value
39 info="${18}"       # a short description of the alarm
40
41 # -----------------------------------------------------------------------------
42 # screen statuses we don't need to send a notification
43
44 # don't do anything if this is not WARNING, CRITICAL or CLEAR
45 if [ "${status}" != "WARNING" -a "${status}" != "CRITICAL" -a "${status}" != "CLEAR" ]
46 then
47     echo >&2 "${me}: not sending notification for ${status} on '${chart}.${name}'"
48     exit 1
49 fi
50
51 # don't do anything if this is CLEAR, but it was not WARNING or CRITICAL
52 if [ "${old_status}" != "WARNING" -a "${old_status}" != "CRITICAL" -a "${status}" = "CLEAR" ]
53 then
54     echo >&2 "${me}: not sending notification for ${status} on '${chart}.${name}' (last status was ${old_status})"
55     exit 1
56 fi
57
58 # -----------------------------------------------------------------------------
59 # load configuration
60
61 # this is defined here so that private registries
62 # can setup their own
63 # images_base_url="${NETDATA_REGISTRY_URL}"
64 images_base_url="https://registry.my-netdata.io"
65
66 # needed commands
67 # if empty they will be searched in the system path
68 curl=
69 sendmail=
70
71 # enable / disable features
72 SEND_SLACK="YES"
73 SEND_PUSHOVER="YES"
74 SEND_EMAIL="YES"
75
76 # slack configs
77 SLACK_WEBHOOK_URL=
78 DEFAULT_RECIPIENT_SLACK=
79 declare -A role_recipients_slack=()
80
81 # pushover configs
82 PUSHOVER_APP_TOKEN=
83 DEFAULT_RECIPIENT_PUSHOVER=
84 declare -A role_recipients_pushover=()
85
86 # email configs
87 DEFAULT_RECIPIENT_EMAIL="root"
88 declare -A role_recipients_email=()
89
90 # load the user configuration
91 # this will overwrite the variables above
92 if [ -f "${NETDATA_CONFIG_DIR}/health_alarm_notify.conf" ]
93     then
94     source "${NETDATA_CONFIG_DIR}/health_alarm_notify.conf"
95 fi
96
97 # -----------------------------------------------------------------------------
98 # find the recipient's addresses per method
99
100 declare -A arr_slack=()
101 declare -A arr_pushover=()
102 declare -A arr_email=()
103
104 # netdata may call us with multiple recipients
105 # so, here we find the unique ones
106 for x in ${recipient//,/ }
107 do
108     # email
109     a="${role_recipients_email[${recipient}]}"
110     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_EMAIL}"
111     for r in ${a//,/ }; do arr_email[${r}]="1"; done
112
113     # pushover
114     a="${role_recipients_pushover[${recipient}]}"
115     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_PUSHOVER}"
116     for r in ${a//,/ }; do arr_pushover[${r}]="1"; done
117
118     # slack
119     a="${role_recipients_slack[${recipient}]}"
120     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_SLACK}"
121     for r in ${a//,/ }; do arr_slack[${r}]="1"; done
122 done
123
124 # build the list of slack recipients (channels)
125 to_slack="${!arr_slack[*]}"
126 [ -z "${to_slack}" ] && SEND_SLACK="NO"
127
128 # build the list of pushover recipients (user tokens)
129 to_pushover="${!arr_pushover[*]}"
130 [ -z "${to_pushover}" ] && SEND_PUSHOVER="NO"
131
132 # build the list of email recipients (email addresses)
133 to_email=
134 for x in "${!arr_email[@]}"
135 do
136     [ ! -z "${to_email}" ] && to_email="${to_email}, "
137     to_email="${to_email}${x}"
138 done
139 [ -z "${to_email}" ] && to_email="root"
140
141
142 # -----------------------------------------------------------------------------
143 # verify the delivery methods supported
144
145 # check slack
146 [ -z "${SLACK_WEBHOOK_URL}" ] && SEND_SLACK="NO"
147
148 # check pushover
149 [ -z "${PUSHOVER_APP_TOKEN}" ] && SEND_PUSHOVER="NO"
150
151 if [ \( "${SEND_PUSHOVER}" = "YES" -o "${SEND_SLACK}" = "YES" \) -a -z "${curl}" ]
152     then
153     curl="$(which curl 2>/dev/null || command -v curl 2>/dev/null)"
154     if [ -z "${curl}" ]
155         then
156         SEND_PUSHOVER="NO"
157         SEND_SLACK="NO"
158     fi
159 fi
160
161 if [ "${SEND_EMAIL}" = "YES" -a -z "${sendmail}" ]
162     then
163     sendmail="$(which sendmail 2>/dev/null || command -v sendmail 2>/dev/null)"
164     [ -z "${sendmail}" ] && SEND_EMAIL="NO"
165 fi
166
167 # check that we have at least a method enabled
168 if [ "${SEND_EMAIL}" != "YES" -a "${SEND_PUSHOVER}" != "YES" -a "${SEND_SLACK}" != "YES" ]
169     then
170     echo >&2 "I don't have a means to send a notification. Sorry!"
171     exit 1
172 fi
173
174 # -----------------------------------------------------------------------------
175 # get the system hostname
176
177 [ -z "${host}" ] && host="${NETDATA_HOSTNAME}"
178 [ -z "${host}" ] && host="${NETDATA_REGISTRY_HOSTNAME}"
179 [ -z "${host}" ] && host="$(hostname 2>/dev/null)"
180
181 # -----------------------------------------------------------------------------
182 # get the date the alarm happened
183
184 date="$(date --date=@${when} 2>/dev/null)"
185 [ -z "${date}" ] && date="$(date 2>/dev/null)"
186
187 # -----------------------------------------------------------------------------
188 # URL encode a string
189
190 urlencode() {
191     local string="${1}" strlen encoded pos c o
192
193     strlen=${#string}
194     for (( pos=0 ; pos<strlen ; pos++ ))
195     do
196         c=${string:$pos:1}
197         case "$c" in
198             [-_.~a-zA-Z0-9])
199                 o="${c}"
200                 ;;
201
202             *)
203                 printf -v o '%%%02x' "'$c"
204                 ;;
205         esac
206         encoded+="${o}"
207     done
208
209     REPLY="${encoded}"
210     echo "${REPLY}"
211 }
212
213 # -----------------------------------------------------------------------------
214 # convert a duration in seconds, to a human readable duration
215 # using DAYS, MINUTES, SECONDS
216
217 duration4human() {
218     local s="${1}" d=0 h=0 m=0 ds="day" hs="hour" ms="minute" ss="second" ret
219     d=$(( s / 86400 ))
220     s=$(( s - (d * 86400) ))
221     h=$(( s / 3600 ))
222     s=$(( s - (h * 3600) ))
223     m=$(( s / 60 ))
224     s=$(( s - (m * 60) ))
225
226     if [ ${d} -gt 0 ]
227     then
228         [ ${m} -ge 30 ] && h=$(( h + 1 ))
229         [ ${d} -gt 1 ] && ds="days"
230         [ ${h} -gt 1 ] && hs="hours"
231         if [ ${h} -gt 0 ]
232         then
233             ret="${d} ${ds} and ${h} ${hs}"
234         else
235             ret="${d} ${ds}"
236         fi
237     elif [ ${h} -gt 0 ]
238     then
239         [ ${s} -ge 30 ] && m=$(( m + 1 ))
240         [ ${h} -gt 1 ] && hs="hours"
241         [ ${m} -gt 1 ] && ms="minutes"
242         if [ ${m} -gt 0 ]
243         then
244             ret="${h} ${hs} and ${m} ${ms}"
245         else
246             ret="${h} ${hs}"
247         fi
248     elif [ ${m} -gt 0 ]
249     then
250         [ ${m} -gt 1 ] && ms="minutes"
251         [ ${s} -gt 1 ] && ss="seconds"
252         if [ ${s} -gt 0 ]
253         then
254             ret="${m} ${ms} and ${s} ${ss}"
255         else
256             ret="${m} ${ms}"
257         fi
258     else
259         [ ${s} -gt 1 ] && ss="seconds"
260         ret="${s} ${ss}"
261     fi
262
263     REPLY="${ret}"
264     echo "${REPLY}"
265 }
266
267 # -----------------------------------------------------------------------------
268 # email sender
269
270 send_email() {
271     local ret=
272     if [ "${SEND_EMAIL}" = "YES" ]
273         then
274
275         "${sendmail}" -t
276         ret=$?
277
278         if [ $ret -eq 0 ]
279         then
280             echo >&2 "${me}: Sent email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}'"
281             return 0
282         else
283             echo >&2 "${me}: Failed to send email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}' with error code ${ret}."
284             return 1
285         fi
286     fi
287
288     return 1
289 }
290
291 # -----------------------------------------------------------------------------
292 # pushover sender
293
294 send_pushover() {
295     local apptoken="${1}" usertokens="${2}" when="${3}" url="${4}" status="${5}" title="${6}" message="${7}" httpcode sent=0 user priority
296
297     if [ "${SEND_PUSHOVER}" = "YES" -a ! -z "${apptoken}" -a ! -z "${usertokens}" -a ! -z "${title}" -a ! -z "${message}" ]
298         then
299
300         priority=0
301         [ "${status}" = "CRITICAL" ] && priority=1
302
303         for user in ${usertokens}
304         do
305             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
306                 --form-string "token=${apptoken}" \
307                 --form-string "user=${user}" \
308                 --form-string "html=1" \
309                 --form-string "title=${title}" \
310                 --form-string "message=${message}" \
311                 --form-string "timestamp=${when}" \
312                 --form-string "url=${url}" \
313                 --form-string "url_title=Open netdata dashboard to view the alarm" \
314                 --form-string "priority=${priority}" \
315                 https://api.pushover.net/1/messages.json)
316
317             if [ "${httpcode}" == "200" ]
318             then
319                 echo >&2 "${me}: Sent pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
320                 sent=$((sent + 1))
321             else
322                 echo >&2 "${me}: Failed to send pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}' with HTTP error code ${httpcode}."
323             fi
324         done
325
326         [ ${sent} -gt 0 ] && return 0
327     fi
328
329     return 1
330 }
331
332 # -----------------------------------------------------------------------------
333 # slack sender
334
335 send_slack() {
336     local webhook="${1}" channels="${2}" when="${3}" username="${4}" image="${5}" author="${6}" httpcode sent=0 channel color
337
338     if [ "${SEND_SLACK}" = "YES" -a ! -z "${webhook}" -a ! -z "${channels}" -a ! -z "${username}" -a ! -z "${image}" -a ! -z "${author}" ]
339         then
340
341         case "${status}" in
342             WARNING) color="warning" ;;
343             CRITICAL) color="danger" ;;
344             CLEAR) color="good" ;;
345             *) color="#777777" ;;
346         esac
347
348         for channel in ${channels}
349         do
350             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null -X POST --data-urlencode \
351                 "payload={\"channel\": \"#${channel}\", \"username\": \"${username}\", \"text\": \"${host} ${status_message} - ${author} ${raised_for} - click <${goto_url}|here> to view the netdata dashboard.\", \"icon_url\": \"${image}\", \"attachments\": [{\"fallback\": \"${alarm} - ${info}\", \"color\": \"${color}\", \"title\": \"${alarm}\", \"title_link\": \"${goto_url}\", \"text\": \"${info}\", \"footer\": \"netdata\", \"footer_icon\": \"${images_base_url}/images/seo-performance-128.png\", \"ts\": ${when}}]}" \
352                 "${webhook}")
353
354             if [ "${httpcode}" == "200" ]
355             then
356                 echo >&2 "${me}: Sent slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
357                 sent=$((sent + 1))
358             else
359                 echo >&2 "${me}: Failed to send slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
360             fi
361         done
362
363         [ ${sent} -gt 0 ] && return 0
364     fi
365
366     return 1
367 }
368
369
370 # -----------------------------------------------------------------------------
371 # prepare the content of the notification
372
373 # the url to send the user on click
374 urlencode "${NETDATA_REGISTRY_HOSTNAME}" >/dev/null; url_host="${REPLY}"
375 urlencode "${chart}" >/dev/null; url_chart="${REPLY}"
376 urlencode "${family}" >/dev/null; url_family="${REPLY}"
377 urlencode "${name}" >/dev/null; url_name="${REPLY}"
378 goto_url="${NETDATA_REGISTRY_URL}/goto-host-from-alarm.html?host=${url_host}&chart=${url_chart}&family=${url_family}&alarm=${url_name}&alarm_unique_id=${unique_id}&alarm_id=${alarm_id}&alarm_event_id=${event_id}"
379
380 # the severity of the alarm
381 severity="${status}"
382
383 # the time the alarm was raised
384 duration4human ${duration} >/dev/null; duration_txt="${REPLY}"
385 duration4human ${non_clear_duration} >/dev/null; non_clear_duration_txt="${REPLY}"
386 raised_for="(was ${old_status,,} for ${duration_txt}"
387
388 # the key status message
389 status_message="status unknown"
390
391 # the color of the alarm
392 color="grey"
393
394 # the alarm value
395 alarm="${name//_/ } = ${value} ${units}"
396
397 # the image of the alarm
398 image="${images_base_url}/images/seo-performance-128.png"
399
400 # prepare the title based on status
401 case "${status}" in
402         CRITICAL)
403         image="${images_base_url}/images/alert-128-red.png"
404         status_message="is critical"
405         color="#ca414b"
406         ;;
407
408     WARNING)
409         image="${images_base_url}/images/alert-128-orange.png"
410         status_message="needs attention"
411         color="#caca4b"
412                 ;;
413
414         CLEAR)
415         image="${images_base_url}/images/check-mark-2-128-green.png"
416         status_message="recovered"
417                 color="#77ca6d"
418
419                 # don't show the value when the status is CLEAR
420                 # for certain alarms, this value might not have any meaning
421                 alarm="${name//_/ }"
422                 ;;
423 esac
424
425 if [ "${status}" = "CLEAR" ]
426 then
427     severity="Recovered from ${old_status}"
428     if [ $non_clear_duration -gt $duration ]
429     then
430         raised_for="(alarm was raised for ${non_clear_duration_txt})"
431     fi
432
433 elif [ "${old_status}" = "WARNING" -a "${status}" = "CRITICAL" ]
434 then
435     severity="Escalated to ${status}"
436     if [ $non_clear_duration -gt $duration ]
437     then
438         raised_for="(alarm is raised for ${non_clear_duration_txt})"
439     fi
440
441 elif [ "${old_status}" = "CRITICAL" -a "${status}" = "WARNING" ]
442 then
443     severity="Demoted to ${status}"
444     if [ $non_clear_duration -gt $duration ]
445     then
446         raised_for="(alarm is raised for ${non_clear_duration_txt})"
447     fi
448
449 else
450     raised_for=
451 fi
452
453 # prepare HTML versions of elements
454 info_html=
455 [ ! -z "${info}" ] && info_html=" <small><br/>${info}</small>"
456
457 raised_for_html=
458 [ ! -z "${raised_for}" ] && raised_for_html="<br/><small>${raised_for}</small>"
459
460 # -----------------------------------------------------------------------------
461 # send the slack notification
462
463 # slack aggregates posts from the same username
464 # so we use "${host} ${status}" as the bot username, to make them diff
465
466 send_slack "${SLACK_WEBHOOK_URL}" "${to_slack}" "${when}" "${host} ${status}" "${image}" "${chart} (${family})"
467 SENT_SLACK=$?
468
469 # -----------------------------------------------------------------------------
470 # send the pushover notification
471
472 send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${host} ${status_message} - ${name//_/ } - ${chart}" "
473 <font color=\"${color}\"><b>${alarm}</b></font>${info_html}<br/>&nbsp;
474 <small><b>${chart}</b><br/>Chart<br/>&nbsp;</small>
475 <small><b>${family}</b><br/>Family<br/>&nbsp;</small>
476 <small><b>${severity}</b><br/>Severity<br/>&nbsp;</small>
477 <small><b>${date}${raised_for_html}</b><br/>Time<br/>&nbsp;</small>
478 <a href=\"${goto_url}\">View Netdata</a><br/>&nbsp;
479 <small><small>The source of this alarm is line ${src}</small></small>
480 "
481
482 SENT_PUSHOVER=$?
483
484 # -----------------------------------------------------------------------------
485 # send the email
486
487 send_email <<EOF
488 To: ${to_email}
489 Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
490 Content-Type: text/html
491
492 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
493 <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;">
494 <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;">
495 <table>
496     <tbody>
497     <tr>
498         <td style="vertical-align: top;" valign="top"></td>
499         <td width="700" style="vertical-align: top; display: block !important; max-width: 700px !important; clear: both !important; margin: 0 auto; padding: 0;" valign="top">
500             <div style="max-width: 700px; display: block; margin: 0 auto; padding: 20px;">
501                 <table width="100%" cellpadding="0" cellspacing="0" style="background: #fff; border: 1px solid #e9e9e9;">
502                     <tbody>
503                     <tr>
504                         <td bgcolor="#eee" style="padding: 5px 20px 5px 20px; background-color: #eee;">
505                             <div style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 20px; color: #777; font-weight: bold;">netdata notification</div>
506                         </td>
507                     </tr>
508                     <tr>
509                         <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">
510                             <h1 style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: 400; margin: 0;">${host} ${status_message}</h1>
511                         </td>
512                     </tr>
513                     <tr>
514                         <td style="vertical-align: top;" valign="top">
515                             <div style="margin: 0; padding: 20px; max-width: 700px;">
516                                 <table width="100%" cellpadding="0" cellspacing="0" style="max-width:700px">
517                                     <tbody>
518                                     <tr>
519                                         <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">
520                                             <span>${chart}</span>
521                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Chart</span>
522                                         </td>
523                                     </tr>
524                                     <tr style="margin: 0; padding: 0;">
525                                         <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">
526                                             <span><b>${alarm}</b>${info_html}</span>
527                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Alarm</span>
528                                         </td>
529                                     </tr>
530                                     <tr>
531                                         <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">
532                                             <span>${family}</span>
533                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Family</span>
534                                         </td>
535                                     </tr>
536                                     <tr style="margin: 0; padding: 0;">
537                                         <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">
538                                             <span>${severity}</span>
539                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Severity</span>
540                                         </td>
541                                     </tr>
542                                     <tr style="margin: 0; padding: 0;">
543                                         <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>
544                                             <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>
545                                         </td>
546                                     </tr>
547                                     <tr style="margin: 0; padding: 0;">
548                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;">
549                                             <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>
550                                         </td>
551                                     </tr>
552                                     <tr style="text-align: center; margin: 0; padding: 0;">
553                                         <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>
554                                         </td>
555                                     </tr>
556                                     <tr style="text-align: center; margin: 0; padding: 0;">
557                                         <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
558                                             <a href="https://mynetdata.io/" target="_blank">netdata</a>, the real-time performance monitoring.
559                                         </td>
560                                     </tr>
561                                     </tbody>
562                                 </table>
563                             </div>
564                         </td>
565                     </tr>
566                     </tbody>
567                 </table>
568             </div>
569         </td>
570     </tr>
571     </tbody>
572 </table>
573 </body>
574 </html>
575 EOF
576
577 SENT_EMAIL=$?
578
579 # -----------------------------------------------------------------------------
580 # let netdata know
581
582 # we did send somehting
583 [ ${SENT_EMAIL} -eq 0 -o ${SENT_PUSHOVER} -eq 0 -o ${SENT_SLACK} -eq 0 ] && exit 0
584
585 # we did not send anything
586 exit 1