summaryrefslogtreecommitdiffstats
path: root/health/notifications/alarm-notify.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'health/notifications/alarm-notify.sh.in')
-rwxr-xr-xhealth/notifications/alarm-notify.sh.in41
1 files changed, 20 insertions, 21 deletions
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index 08a32ff10..287cabfef 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -243,7 +243,6 @@ else
total_crit_alarms="${26}" # List of alarms in critical state
classification="${27}" # The class field from .conf files
edit_command_line="${28}" # The command to edit the alarm, with the line number
- sender_host="${29}" # The host sending this notification
fi
# -----------------------------------------------------------------------------
@@ -258,17 +257,6 @@ else
fi
# -----------------------------------------------------------------------------
-# Do the same for sender_host (find a suitable hostname to use, if netdata did not supply a hostname)
-
-if [ -z ${sender_host} ]; then
- this_host=$(hostname -s 2>/dev/null)
- s_host="${this_host}"
- sender_host="${this_host}"
-else
- s_host="${sender_host}"
-fi
-
-# -----------------------------------------------------------------------------
# screen statuses we don't need to send a notification
# don't do anything if this is not WARNING, CRITICAL or CLEAR
@@ -1012,10 +1000,21 @@ send_pushover() {
# pushbullet sender
send_pushbullet() {
- local userapikey="${1}" source_device="${2}" recipients="${3}" url="${4}" title="${5}" message="${6}" httpcode sent=0 user
+ local userapikey="${1}" source_device="${2}" recipients="${3}" url="${4}" title="${5}" message="${6}" httpcode sent=0 userOrChannelTag
if [ "${SEND_PUSHBULLET}" = "YES" ] && [ -n "${userapikey}" ] && [ -n "${recipients}" ] && [ -n "${message}" ] && [ -n "${title}" ]; then
- #https://docs.pushbullet.com/#create-push
- for user in ${recipients}; do
+
+ # https://docs.pushbullet.com/#create-push
+ # Accept specification of user(s) (PushBullet account email address) and/or channel tag(s), separated by spaces.
+ # If recipient begins with a "#" then send to channel tag, otherwise send to email recipient.
+
+ for userOrChannelTag in ${recipients}; do
+ if [ "${userOrChannelTag::1}" = "#" ]; then
+ userOrChannelTag_type="channel_tag"
+ userOrChannelTag="${userOrChannelTag:1}" # Remove hash from start of channel tag (required by pushbullet API)
+ else
+ userOrChannelTag_type="email"
+ fi
+
httpcode=$(docurl \
--header 'Access-Token: '${userapikey}'' \
--header 'Content-Type: application/json' \
@@ -1023,7 +1022,7 @@ send_pushbullet() {
cat <<EOF
{"title": "${title}",
"type": "link",
- "email": "${user}",
+ "${userOrChannelTag_type}": "${userOrChannelTag}",
"body": "$(echo -n ${message})",
"url": "${url}",
"source_device_iden": "${source_device}"}
@@ -1031,10 +1030,10 @@ EOF
) "https://api.pushbullet.com/v2/pushes" -X POST)
if [ "${httpcode}" = "200" ]; then
- info "sent pushbullet notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
+ info "sent pushbullet notification for: ${host} ${chart}.${name} is ${status} to '${userOrChannelTag}'"
sent=$((sent + 1))
else
- error "failed to send pushbullet notification for: ${host} ${chart}.${name} is ${status} to '${user}' with HTTP response status code ${httpcode}."
+ error "failed to send pushbullet notification for: ${host} ${chart}.${name} is ${status} to '${userOrChannelTag}' with HTTP response status code ${httpcode}."
fi
done
@@ -2845,7 +2844,7 @@ if [ -n "$total_crit_alarms" ]; then
fi
if [ -n "$edit_command_line" ]; then
- IFS='=' read -r edit_command line <<<"$edit_command_line"
+ IFS='=' read -r edit_command line s_host <<<"$edit_command_line"
fi
IFS='' read -r -d '' email_html_part <<EOF
@@ -3258,7 +3257,7 @@ Content-Transfer-Encoding: 8bit
</tr>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;padding-left:0;word-break:break-word;">
- <div style="font-family:Open Sans, sans-serif;font-size:14px;line-height:1.3;text-align:left;color:#35414A;">Discuss and troubleshoot with others on the Netdata <a href="https://community.netdata.cloud/" class="link" style="color: #00AB44; text-decoration: none;">community forums</a></div>
+ <div style="font-family:Open Sans, sans-serif;font-size:14px;line-height:1.3;text-align:left;color:#35414A;">Join the troubleshooting discussion for this alert on our <a href="https://community.netdata.cloud/t/${name//[._]/-}" class="link" style="color: #00AB44; text-decoration: none;">community forums</a>.</div>
</td>
</tr>
</tbody>
@@ -3329,7 +3328,7 @@ Content-Transfer-Encoding: 8bit
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;padding-top:8px;padding-left:0;word-break:break-word;">
<div style="font-family:Open Sans, sans-serif;font-size:12px;line-height:1.3;text-align:left;color:#35414A;">${edit_command} <br>
- The alarm to edit is at line {${line}}</div>
+ <br>The alarm to edit is at line ${line}</div>
</td>
</tr>
</tbody>