]> arthur.barton.de Git - netdata.git/blob - plugins.d/alarm-notify.sh
Merge pull request #967 from ktsaou/master
[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 # filter recipients based on the criticality of each
99
100 filter_recipient_by_criticality() {
101     local method="${1}" x="${2}" r s
102     shift
103
104     r="${x/|*/}"
105     s="${x/*|/}"
106
107     # no severity filtering for this person
108     [ "${r}" = "${s}" ] && return 0
109
110     # the severity is invalid
111     s="${s^^}"
112     [ "${s}" != "CRITICAL" ] && return 0
113
114     # the new or the old status matches the severity
115     if [ "${s}" = "${status}" -o "${s}" = "${old_status}" ]
116         then
117         [ ! -d "${NETDATA_CACHE_DIR}/alarm-notify/${method}/${r}" ] && \
118             mkdir -p "${NETDATA_CACHE_DIR}/alarm-notify/${method}/${r}"
119
120         # we need to keep track of the notifications we sent
121         # so that the same user will receive the recovery
122         # even if old_status does not match the required severity
123         touch "${NETDATA_CACHE_DIR}/alarm-notify/${method}/${r}/${alarm_id}"
124         return 0
125     fi
126
127     # it is a cleared alarm we have sent notification for
128     if [ "${status}" != "WARNING" -a "${status}" != "CRITICAL" -a -f "${NETDATA_CACHE_DIR}/alarm-notify/${method}/${r}/${alarm_id}" ]
129         then
130         rm "${NETDATA_CACHE_DIR}/alarm-notify/${method}/${r}/${alarm_id}"
131         return 0
132     fi
133
134     return 1
135 }
136
137 # -----------------------------------------------------------------------------
138 # find the recipient's addresses per method
139
140 declare -A arr_slack=()
141 declare -A arr_pushover=()
142 declare -A arr_email=()
143
144 # netdata may call us with multiple recipients
145 # so, here we find the unique ones
146 for x in ${recipient//,/ }
147 do
148     # email
149     a="${role_recipients_email[${recipient}]}"
150     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_EMAIL}"
151     for r in ${a//,/ }
152     do
153         filter_recipient_by_criticality email "${r}" && arr_email[${r/|*/}]="1"
154     done
155
156     # pushover
157     a="${role_recipients_pushover[${recipient}]}"
158     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_PUSHOVER}"
159     for r in ${a//,/ }
160     do
161         filter_recipient_by_criticality pushover "${r}" && arr_pushover[${r/|*/}]="1"
162     done
163
164     # slack
165     a="${role_recipients_slack[${recipient}]}"
166     [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_SLACK}"
167     for r in ${a//,/ }
168     do
169         filter_recipient_by_criticality slack "${r}" && arr_slack[${r/|*/}]="1"
170     done
171 done
172
173 # build the list of slack recipients (channels)
174 to_slack="${!arr_slack[*]}"
175 [ -z "${to_slack}" ] && SEND_SLACK="NO"
176
177 # build the list of pushover recipients (user tokens)
178 to_pushover="${!arr_pushover[*]}"
179 [ -z "${to_pushover}" ] && SEND_PUSHOVER="NO"
180
181 # build the list of email recipients (email addresses)
182 to_email=
183 for x in "${!arr_email[@]}"
184 do
185     [ ! -z "${to_email}" ] && to_email="${to_email}, "
186     to_email="${to_email}${x}"
187 done
188 [ -z "${to_email}" ] && SEND_EMAIL="NO"
189
190
191 # -----------------------------------------------------------------------------
192 # verify the delivery methods supported
193
194 # check slack
195 [ -z "${SLACK_WEBHOOK_URL}" ] && SEND_SLACK="NO"
196
197 # check pushover
198 [ -z "${PUSHOVER_APP_TOKEN}" ] && SEND_PUSHOVER="NO"
199
200 if [ \( "${SEND_PUSHOVER}" = "YES" -o "${SEND_SLACK}" = "YES" \) -a -z "${curl}" ]
201     then
202     curl="$(which curl 2>/dev/null || command -v curl 2>/dev/null)"
203     if [ -z "${curl}" ]
204         then
205         SEND_PUSHOVER="NO"
206         SEND_SLACK="NO"
207     fi
208 fi
209
210 if [ "${SEND_EMAIL}" = "YES" -a -z "${sendmail}" ]
211     then
212     sendmail="$(which sendmail 2>/dev/null || command -v sendmail 2>/dev/null)"
213     [ -z "${sendmail}" ] && SEND_EMAIL="NO"
214 fi
215
216 # check that we have at least a method enabled
217 if [ "${SEND_EMAIL}" != "YES" -a "${SEND_PUSHOVER}" != "YES" -a "${SEND_SLACK}" != "YES" ]
218     then
219     echo >&2 "I don't have a means to send a notification. Sorry!"
220     exit 1
221 fi
222
223 # -----------------------------------------------------------------------------
224 # get the system hostname
225
226 [ -z "${host}" ] && host="${NETDATA_HOSTNAME}"
227 [ -z "${host}" ] && host="${NETDATA_REGISTRY_HOSTNAME}"
228 [ -z "${host}" ] && host="$(hostname 2>/dev/null)"
229
230 # -----------------------------------------------------------------------------
231 # get the date the alarm happened
232
233 date="$(date --date=@${when} 2>/dev/null)"
234 [ -z "${date}" ] && date="$(date 2>/dev/null)"
235
236 # -----------------------------------------------------------------------------
237 # URL encode a string
238
239 urlencode() {
240     local string="${1}" strlen encoded pos c o
241
242     strlen=${#string}
243     for (( pos=0 ; pos<strlen ; pos++ ))
244     do
245         c=${string:$pos:1}
246         case "$c" in
247             [-_.~a-zA-Z0-9])
248                 o="${c}"
249                 ;;
250
251             *)
252                 printf -v o '%%%02x' "'$c"
253                 ;;
254         esac
255         encoded+="${o}"
256     done
257
258     REPLY="${encoded}"
259     echo "${REPLY}"
260 }
261
262 # -----------------------------------------------------------------------------
263 # convert a duration in seconds, to a human readable duration
264 # using DAYS, MINUTES, SECONDS
265
266 duration4human() {
267     local s="${1}" d=0 h=0 m=0 ds="day" hs="hour" ms="minute" ss="second" ret
268     d=$(( s / 86400 ))
269     s=$(( s - (d * 86400) ))
270     h=$(( s / 3600 ))
271     s=$(( s - (h * 3600) ))
272     m=$(( s / 60 ))
273     s=$(( s - (m * 60) ))
274
275     if [ ${d} -gt 0 ]
276     then
277         [ ${m} -ge 30 ] && h=$(( h + 1 ))
278         [ ${d} -gt 1 ] && ds="days"
279         [ ${h} -gt 1 ] && hs="hours"
280         if [ ${h} -gt 0 ]
281         then
282             ret="${d} ${ds} and ${h} ${hs}"
283         else
284             ret="${d} ${ds}"
285         fi
286     elif [ ${h} -gt 0 ]
287     then
288         [ ${s} -ge 30 ] && m=$(( m + 1 ))
289         [ ${h} -gt 1 ] && hs="hours"
290         [ ${m} -gt 1 ] && ms="minutes"
291         if [ ${m} -gt 0 ]
292         then
293             ret="${h} ${hs} and ${m} ${ms}"
294         else
295             ret="${h} ${hs}"
296         fi
297     elif [ ${m} -gt 0 ]
298     then
299         [ ${m} -gt 1 ] && ms="minutes"
300         [ ${s} -gt 1 ] && ss="seconds"
301         if [ ${s} -gt 0 ]
302         then
303             ret="${m} ${ms} and ${s} ${ss}"
304         else
305             ret="${m} ${ms}"
306         fi
307     else
308         [ ${s} -gt 1 ] && ss="seconds"
309         ret="${s} ${ss}"
310     fi
311
312     REPLY="${ret}"
313     echo "${REPLY}"
314 }
315
316 # -----------------------------------------------------------------------------
317 # email sender
318
319 send_email() {
320     local ret=
321     if [ "${SEND_EMAIL}" = "YES" ]
322         then
323
324         "${sendmail}" -t
325         ret=$?
326
327         if [ $ret -eq 0 ]
328         then
329             echo >&2 "${me}: Sent email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}'"
330             return 0
331         else
332             echo >&2 "${me}: Failed to send email notification for: ${host} ${chart}.${name} is ${status} to '${to_email}' with error code ${ret}."
333             return 1
334         fi
335     fi
336
337     return 1
338 }
339
340 # -----------------------------------------------------------------------------
341 # pushover sender
342
343 send_pushover() {
344     local apptoken="${1}" usertokens="${2}" when="${3}" url="${4}" status="${5}" title="${6}" message="${7}" httpcode sent=0 user priority
345
346     if [ "${SEND_PUSHOVER}" = "YES" -a ! -z "${apptoken}" -a ! -z "${usertokens}" -a ! -z "${title}" -a ! -z "${message}" ]
347         then
348
349         # https://pushover.net/api
350         priority=-2
351         case "${status}" in
352             CLEAR) priority=-1;;   # low priority: no sound or vibration
353             WARNING) priotity=0;;  # normal priority: respect quiet hours
354             CRITICAL) priority=1;; # high priority: bypass quiet hours
355             *) priority=-2;;       # lowest priority: no notification at all
356         esac
357
358         for user in ${usertokens}
359         do
360             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
361                 --form-string "token=${apptoken}" \
362                 --form-string "user=${user}" \
363                 --form-string "html=1" \
364                 --form-string "title=${title}" \
365                 --form-string "message=${message}" \
366                 --form-string "timestamp=${when}" \
367                 --form-string "url=${url}" \
368                 --form-string "url_title=Open netdata dashboard to view the alarm" \
369                 --form-string "priority=${priority}" \
370                 https://api.pushover.net/1/messages.json)
371
372             if [ "${httpcode}" == "200" ]
373             then
374                 echo >&2 "${me}: Sent pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
375                 sent=$((sent + 1))
376             else
377                 echo >&2 "${me}: Failed to send pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}' with HTTP error code ${httpcode}."
378             fi
379         done
380
381         [ ${sent} -gt 0 ] && return 0
382     fi
383
384     return 1
385 }
386
387 # -----------------------------------------------------------------------------
388 # slack sender
389
390 send_slack() {
391     local webhook="${1}" channels="${2}" when="${3}" username="${4}" image="${5}" httpcode sent=0 channel color
392
393     if [ "${SEND_SLACK}" = "YES" -a ! -z "${webhook}" -a ! -z "${channels}" -a ! -z "${username}" -a ! -z "${image}" ]
394         then
395
396         case "${status}" in
397             WARNING) color="warning" ;;
398             CRITICAL) color="danger" ;;
399             CLEAR) color="good" ;;
400             *) color="#777777" ;;
401         esac
402
403         for channel in ${channels}
404         do
405             httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null -X POST --data-urlencode \
406                 "payload={\"channel\": \"#${channel}\", \"username\": \"${username}\", \"text\": \"${host} ${status_message} - ${chart} (${family}) ${alarm} - 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\": \"${chart} (${family}): ${info}\", \"footer\": \"netdata\", \"footer_icon\": \"${images_base_url}/images/seo-performance-128.png\", \"ts\": ${when}}]}" \
407                 "${webhook}")
408
409             if [ "${httpcode}" == "200" ]
410             then
411                 echo >&2 "${me}: Sent slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
412                 sent=$((sent + 1))
413             else
414                 echo >&2 "${me}: Failed to send slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
415             fi
416         done
417
418         [ ${sent} -gt 0 ] && return 0
419     fi
420
421     return 1
422 }
423
424
425 # -----------------------------------------------------------------------------
426 # prepare the content of the notification
427
428 # the url to send the user on click
429 urlencode "${NETDATA_REGISTRY_HOSTNAME}" >/dev/null; url_host="${REPLY}"
430 urlencode "${chart}" >/dev/null; url_chart="${REPLY}"
431 urlencode "${family}" >/dev/null; url_family="${REPLY}"
432 urlencode "${name}" >/dev/null; url_name="${REPLY}"
433 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}"
434
435 # the severity of the alarm
436 severity="${status}"
437
438 # the time the alarm was raised
439 duration4human ${duration} >/dev/null; duration_txt="${REPLY}"
440 duration4human ${non_clear_duration} >/dev/null; non_clear_duration_txt="${REPLY}"
441 raised_for="(was ${old_status,,} for ${duration_txt})"
442
443 # the key status message
444 status_message="status unknown"
445
446 # the color of the alarm
447 color="grey"
448
449 # the alarm value
450 alarm="${name//_/ } = ${value} ${units}"
451
452 # the image of the alarm
453 image="${images_base_url}/images/seo-performance-128.png"
454
455 # prepare the title based on status
456 case "${status}" in
457         CRITICAL)
458         image="${images_base_url}/images/alert-128-red.png"
459         status_message="is critical"
460         color="#ca414b"
461         ;;
462
463     WARNING)
464         image="${images_base_url}/images/alert-128-orange.png"
465         status_message="needs attention"
466         color="#caca4b"
467                 ;;
468
469         CLEAR)
470         image="${images_base_url}/images/check-mark-2-128-green.png"
471         status_message="recovered"
472                 color="#77ca6d"
473
474                 # don't show the value when the status is CLEAR
475                 # for certain alarms, this value might not have any meaning
476                 alarm="${name//_/ } ${raised_for}"
477                 ;;
478 esac
479
480 if [ "${status}" = "CLEAR" ]
481 then
482     severity="Recovered from ${old_status}"
483     if [ $non_clear_duration -gt $duration ]
484     then
485         raised_for="(alarm was raised for ${non_clear_duration_txt})"
486     fi
487
488 elif [ "${old_status}" = "WARNING" -a "${status}" = "CRITICAL" ]
489 then
490     severity="Escalated to ${status}"
491     if [ $non_clear_duration -gt $duration ]
492     then
493         raised_for="(alarm is raised for ${non_clear_duration_txt})"
494     fi
495
496 elif [ "${old_status}" = "CRITICAL" -a "${status}" = "WARNING" ]
497 then
498     severity="Demoted to ${status}"
499     if [ $non_clear_duration -gt $duration ]
500     then
501         raised_for="(alarm is raised for ${non_clear_duration_txt})"
502     fi
503
504 else
505     raised_for=
506 fi
507
508 # prepare HTML versions of elements
509 info_html=
510 [ ! -z "${info}" ] && info_html=" <small><br/>${info}</small>"
511
512 raised_for_html=
513 [ ! -z "${raised_for}" ] && raised_for_html="<br/><small>${raised_for}</small>"
514
515 # -----------------------------------------------------------------------------
516 # send the slack notification
517
518 # slack aggregates posts from the same username
519 # so we use "${host} ${status}" as the bot username, to make them diff
520
521 send_slack "${SLACK_WEBHOOK_URL}" "${to_slack}" "${when}" "${host} ${status}" "${image}"
522 SENT_SLACK=$?
523
524 # -----------------------------------------------------------------------------
525 # send the pushover notification
526
527 send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${host} ${status_message} - ${name//_/ } - ${chart}" "
528 <font color=\"${color}\"><b>${alarm}</b></font>${info_html}<br/>&nbsp;
529 <small><b>${chart}</b><br/>Chart<br/>&nbsp;</small>
530 <small><b>${family}</b><br/>Family<br/>&nbsp;</small>
531 <small><b>${severity}</b><br/>Severity<br/>&nbsp;</small>
532 <small><b>${date}${raised_for_html}</b><br/>Time<br/>&nbsp;</small>
533 <a href=\"${goto_url}\">View Netdata</a><br/>&nbsp;
534 <small><small>The source of this alarm is line ${src}</small></small>
535 "
536
537 SENT_PUSHOVER=$?
538
539 # -----------------------------------------------------------------------------
540 # send the email
541
542 send_email <<EOF
543 To: ${to_email}
544 Subject: ${host} ${status_message} - ${name//_/ } - ${chart}
545 Content-Type: text/html
546
547 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
548 <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;">
549 <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;">
550 <table>
551     <tbody>
552     <tr>
553         <td style="vertical-align: top;" valign="top"></td>
554         <td width="700" style="vertical-align: top; display: block !important; max-width: 700px !important; clear: both !important; margin: 0 auto; padding: 0;" valign="top">
555             <div style="max-width: 700px; display: block; margin: 0 auto; padding: 20px;">
556                 <table width="100%" cellpadding="0" cellspacing="0" style="background: #fff; border: 1px solid #e9e9e9;">
557                     <tbody>
558                     <tr>
559                         <td bgcolor="#eee" style="padding: 5px 20px 5px 20px; background-color: #eee;">
560                             <div style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 20px; color: #777; font-weight: bold;">netdata notification</div>
561                         </td>
562                     </tr>
563                     <tr>
564                         <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">
565                             <h1 style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-weight: 400; margin: 0;">${host} ${status_message}</h1>
566                         </td>
567                     </tr>
568                     <tr>
569                         <td style="vertical-align: top;" valign="top">
570                             <div style="margin: 0; padding: 20px; max-width: 700px;">
571                                 <table width="100%" cellpadding="0" cellspacing="0" style="max-width:700px">
572                                     <tbody>
573                                     <tr>
574                                         <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">
575                                             <span>${chart}</span>
576                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Chart</span>
577                                         </td>
578                                     </tr>
579                                     <tr style="margin: 0; padding: 0;">
580                                         <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">
581                                             <span><b>${alarm}</b>${info_html}</span>
582                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Alarm</span>
583                                         </td>
584                                     </tr>
585                                     <tr>
586                                         <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">
587                                             <span>${family}</span>
588                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Family</span>
589                                         </td>
590                                     </tr>
591                                     <tr style="margin: 0; padding: 0;">
592                                         <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">
593                                             <span>${severity}</span>
594                                             <span style="display: block; color: #666666; font-size: 12px; font-weight: 300; line-height: 1; text-transform: uppercase;">Severity</span>
595                                         </td>
596                                     </tr>
597                                     <tr style="margin: 0; padding: 0;">
598                                         <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>
599                                             <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>
600                                         </td>
601                                     </tr>
602                                     <tr style="margin: 0; padding: 0;">
603                                         <td style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 18px; vertical-align: top; margin: 0; padding: 0 0 20px;">
604                                             <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>
605                                         </td>
606                                     </tr>
607                                     <tr style="text-align: center; margin: 0; padding: 0;">
608                                         <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>
609                                         </td>
610                                     </tr>
611                                     <tr style="text-align: center; margin: 0; padding: 0;">
612                                         <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
613                                             <a href="https://mynetdata.io/" target="_blank">netdata</a>, the real-time performance monitoring.
614                                         </td>
615                                     </tr>
616                                     </tbody>
617                                 </table>
618                             </div>
619                         </td>
620                     </tr>
621                     </tbody>
622                 </table>
623             </div>
624         </td>
625     </tr>
626     </tbody>
627 </table>
628 </body>
629 </html>
630 EOF
631
632 SENT_EMAIL=$?
633
634 # -----------------------------------------------------------------------------
635 # let netdata know
636
637 # we did send somehting
638 [ ${SENT_EMAIL} -eq 0 -o ${SENT_PUSHOVER} -eq 0 -o ${SENT_SLACK} -eq 0 ] && exit 0
639
640 # we did not send anything
641 exit 1