added field for source device in pushbullet sender
This allows for clearly setting the source of alarm, uniquely identifiable by the unique device id when mentioned. Also helps when running netdata on multiple machines. Using this, alerts from same devices can be grouped together in Pushbullet's interface.
Ashesh Kumar Singh committed
Oct 24, 2017 at 01:51 UTC
9e4fbcc0a6f014c126ff75a778cdc2ff6a047bce
2 files changed
+8
-3
conf.d/health_alarm_notify.conf
+3
@@ -161,6 +161,9 @@ SEND_PUSHBULLET="YES"
161
PUSHBULLET_ACCESS_TOKEN=""
162
DEFAULT_RECIPIENT_PUSHBULLET=""
163
164
+# Device iden of the sending device. Optional.
165
+SOURCE_DEVICE=""
166
+
167
168
#------------------------------------------------------------------------------
169
# Twilio (twilio.com) SMS options
plugins.d/alarm-notify.sh
+5
-3
@@ -249,6 +249,7 @@ declare -A role_recipients_pushover=()
249
250
# pushbullet configs
251
PUSHBULLET_ACCESS_TOKEN=
252
+PUSHBULLET_SOURCE_DEVICE=
253
DEFAULT_RECIPIENT_PUSHBULLET=
254
declare -A role_recipients_pushbullet=()
255
@@ -849,7 +850,7 @@ send_pushover() {
850
# pushbullet sender
851
852
send_pushbullet() {
852
- local userapikey="${1}" recipients="${2}" title="${3}" message="${4}" httpcode sent=0 user
853
+ local userapikey="${1}" source_device="${2}" recipients="${3}" title="${4}" message="{5}" httpcode sent=0 user
854
if [ "${SEND_PUSHBULLET}" = "YES" -a ! -z "${userapikey}" -a ! -z "${recipients}" -a ! -z "${message}" -a ! -z "${title}" ]
855
then
856
#https://docs.pushbullet.com/#create-push
@@ -862,7 +863,8 @@ send_pushbullet() {
863
{"title": "${title}",
864
"type": "note",
865
"email": "${user}",
865
- "body": "$( echo -n ${message})"}
866
+ "body": "$( echo -n ${message})",
867
+ "source_device_iden": "${source_device}"}
868
EOF
869
) "https://api.pushbullet.com/v2/pushes" -X POST)
870
@@ -1409,7 +1411,7 @@ SENT_PUSHOVER=$?
1411
# -----------------------------------------------------------------------------
1412
# send the pushbullet notification
1413
1412
-send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${to_pushbullet}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}\n
1414
+send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${PUSHBULLET_SOURCE_DEVICE}" "${to_pushbullet}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}\n
1415
Severity: ${severity}\n
1416
Chart: ${chart}\n
1417
Family: ${family}\n