summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsourcecodes2 <martin@eshock.com>2022-01-11 10:43:36 +0000
committerGitHub <noreply@github.com>2022-01-11 13:43:36 +0300
commit237c117da6f250ab37af849e7a430ccad3238097 (patch)
tree0aea41da93da65866ce76528216491095c01b554
parent6f3ee178ac3393bc6303b5df58d11b20e3e0b4f4 (diff)
Allow PushBullet notifications to be sent to PushBullet channels (#11850)
Co-authored-by: Tina Luedtke <kickoke@users.noreply.github.com> Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
-rwxr-xr-xhealth/notifications/alarm-notify.sh.in23
-rw-r--r--health/notifications/pushbullet/README.md24
2 files changed, 30 insertions, 17 deletions
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index ad5f4b016c..c9a59413c6 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -1012,10 +1012,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 +1034,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 +1042,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
diff --git a/health/notifications/pushbullet/README.md b/health/notifications/pushbullet/README.md
index 7a098d6a0c..a1c88c703e 100644
--- a/health/notifications/pushbullet/README.md
+++ b/health/notifications/pushbullet/README.md
@@ -14,20 +14,22 @@ And like this on your Android device:
You will need:
-1. Signup and Login to pushbullet.com
-2. Get your Access Token, go to <https://www.pushbullet.com/#settings/account> and create a new one
-3. Fill in the PUSHBULLET_ACCESS_TOKEN with that value
-4. Add the recipient emails to DEFAULT_RECIPIENT_PUSHBULLET
- !!PLEASE NOTE THAT IF THE RECIPIENT DOES NOT HAVE A PUSHBULLET ACCOUNT, PUSHBULLET SERVICE WILL SEND AN EMAIL!!
+1. Sign up and log in to [pushbullet.com](pushbullet.com)
+2. Create a new access token in your [account settings](https://www.pushbullet.com/#settings/account).
+3. Fill in the `PUSHBULLET_ACCESS_TOKEN` with the newly generated access token.
+4. Add the recipient emails or channel tags (each channel tag must be prefixed with #, e.g. #channeltag) to `DEFAULT_RECIPIENT_PUSHBULLET`.
+ > 🚨 The pushbullet notification service will send emails to the email recipient, regardless of if they have a pushbullet account.
-Set them in `/etc/netdata/health_alarm_notify.conf` (to edit it on your system run `/etc/netdata/edit-config health_alarm_notify.conf`), like this:
+To add notification channels, run `/etc/netdata/edit-config health_alarm_notify.conf`
+
+You can change the configuration like this:
```
###############################################################################
# pushbullet (pushbullet.com) push notification options
-# multiple recipients can be given like this:
-# "user1@email.com user2@mail.com"
+# multiple recipients (a combination of email addresses or channel tags) can be given like this:
+# "user1@email.com user2@mail.com #channel1 #channel2"
# enable/disable sending pushbullet notifications
SEND_PUSHBULLET="YES"
@@ -35,14 +37,14 @@ SEND_PUSHBULLET="YES"
# Signup and Login to pushbullet.com
# To get your Access Token, go to https://www.pushbullet.com/#settings/account
# And create a new access token
-# Then just set the recipients emails
-# Please note that the if the email in the DEFAULT_RECIPIENT_PUSHBULLET does
+# Then just set the recipients emails and/or channel tags (channel tags must be prefixed with #)
+# Please note that the if an email in the DEFAULT_RECIPIENT_PUSHBULLET does
# not have a pushbullet account, the pushbullet service will send an email
# to that address instead
# Without an access token, Netdata cannot send pushbullet notifications.
PUSHBULLET_ACCESS_TOKEN="o.Sometokenhere"
-DEFAULT_RECIPIENT_PUSHBULLET="admin1@example.com admin3@somemail.com"
+DEFAULT_RECIPIENT_PUSHBULLET="admin1@example.com admin3@somemail.com #examplechanneltag #anotherchanneltag"
```
[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fhealth%2Fnotifications%2Fpushbullet%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)