@cryptotaxi247 / netdata-1 / commits / 3a3b0ce02

Major bug fixes as commented per the pull request https://github.com/firehol/netdata/pull/1070 Modified the code so that it does not require all user access tokens and will accept emails instead Pushbullet service will then validate if the account exists or not, if it does it will push notification, otherwise will send an email Removed the priority variable

Major bug fixes as commented per the pull request https://github.com/firehol/netdata/pull/1070 Modified the code so that it does not require all user access tokens and will accept emails instead Pushbullet service will then validate if the account exists or not, if it does it will push notification, otherwise will send an email Removed the priority variable

Tiago Peralta committed Oct 5, 2016 at 02:10 UTC 3a3b0ce02a89ac049c95723d14b0fc97154a45a5
2 files changed +28 -19
conf.d/health_alarm_notify.conf
+15 -10
@@ -118,16 +118,21 @@ DEFAULT_RECIPIENT_PUSHOVER=""
118 # pushbullet (pushbullet.com) push notification options
119
120 # multiple recipients can be given like this:
121 -# "USERTOKEN1 USERTOKEN2 ..."
121 +# "user1@email.com user2@mail.com"
122
123 # enable/disable sending pushover notifications
124 SEND_PUSHBULLET="YES"
125
126 -# Login to pushover.net to get your pushover app token.
127 -# You need only one for all your netdata servers (or you can have one for
128 -# each of your netdata - your call).
129 -# Without an app token, netdata cannot send pushover notifications.
126 +# Signup and Login to pushbullet.com
127 +# To get your Access Token, go to https://www.pushbullet.com/#settings/account
128 +# And create a new access token
129 +# Then just set the recipients emails
130 +# Please note that the if the email in the DEFAULT_RECIPIENT_PUSHBULLET does
131 +# not have a pushbullet account, the pushbullet service will send an email
132 +# to that address instead
133
134 +# Without an access token, netdata cannot send pushbullet notifications.
135 +PUSBULLET_ACCESS_TOKEN=""
136 DEFAULT_RECIPIENT_PUSHBULLET=""
137
138 ###############################################################################
@@ -183,7 +188,7 @@ role_recipients_email[sysadmin]="${DEFAULT_RECIPIENT_EMAIL}"
188
189 role_recipients_pushover[sysadmin]="${DEFAULT_RECIPIENT_PUSHOVER}"
190
186 -role_recipients_pushover[sysadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
191 +role_recipients_pushbullet[sysadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
192
193 role_recipients_telegram[sysadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
194
@@ -197,7 +202,7 @@ role_recipients_email[domainadmin]="${DEFAULT_RECIPIENT_EMAIL}"
202
203 role_recipients_pushover[domainadmin]="${DEFAULT_RECIPIENT_PUSHOVER}"
204
200 -role_recipients_pushover[domainadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
205 +role_recipients_pushbullet[domainadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
206
207 role_recipients_telegram[domainadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
208
@@ -212,7 +217,7 @@ role_recipients_email[dba]="${DEFAULT_RECIPIENT_EMAIL}"
217
218 role_recipients_pushover[dba]="${DEFAULT_RECIPIENT_PUSHOVER}"
219
215 -role_recipients_pushover[dba]="${DEFAULT_RECIPIENT_PUSHBULLET}"
220 +role_recipients_pushbullet[dba]="${DEFAULT_RECIPIENT_PUSHBULLET}"
221
222 role_recipients_telegram[dba]="${DEFAULT_RECIPIENT_TELEGRAM}"
223
@@ -227,7 +232,7 @@ role_recipients_email[webmaster]="${DEFAULT_RECIPIENT_EMAIL}"
232
233 role_recipients_pushover[webmaster]="${DEFAULT_RECIPIENT_PUSHOVER}"
234
230 -role_recipients_pushover[webmaster]="${DEFAULT_RECIPIENT_PUSHBULLET}"
235 +role_recipients_pushbullet[webmaster]="${DEFAULT_RECIPIENT_PUSHBULLET}"
236
237 role_recipients_telegram[webmaster]="${DEFAULT_RECIPIENT_TELEGRAM}"
238
@@ -242,7 +247,7 @@ role_recipients_email[proxyadmin]="${DEFAULT_RECIPIENT_EMAIL}"
247
248 role_recipients_pushover[proxyadmin]="${DEFAULT_RECIPIENT_PUSHOVER}"
249
245 -role_recipients_pushover[proxyadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
250 +role_recipients_pushbullet[proxyadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
251
252 role_recipients_telegram[proxyadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
253
plugins.d/alarm-notify.sh
+13 -9
@@ -16,6 +16,7 @@
16 # Supported notification methods:
17 # - emails
18 # - pushover.net notifications
19 +# - pushbullet.com push notifications
20 # - slack.com notifications
21 # - telegram.org notifications
22 #
@@ -105,6 +106,7 @@ DEFAULT_RECIPIENT_PUSHOVER=
106 declare -A role_recipients_pushover=()
107
108 # pushbullet configs
109 +PUSHBULLET_ACCESS_TOKEN=
110 DEFAULT_RECIPIENT_PUSHBULLET=
111 declare -A role_recipients_pushbullet=()
112
@@ -197,7 +199,7 @@ do
199 [ "${r}" != "disabled" ] && filter_recipient_by_criticality pushover "${r}" && arr_pushover[${r/|*/}]="1"
200 done
201
200 - # pushover
202 + # pushbullet
203 a="${role_recipients_pushbullet[${x}]}"
204 [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_PUSHBULLET}"
205 for r in ${a//,/ }
@@ -456,20 +458,22 @@ send_pushover() {
458 # pushbullet sender
459
460 send_pushbullet() {
459 - local userapikeys="${1}" message="${2}" title="${3}" httpcode sent=0 user priority
461 + local userapikey="${1}" recipients="${2}" message="${3}" title="${4}" httpcode sent=0 user
462
461 - if [ "${SEND_PUSHBULLET}" = "YES" -a ! -z "${userapikeys}" -a ! -z "${message}" -a ! -z "${title}" ]
463 + if [ "${SEND_PUSHBULLET}" = "YES" -a ! -z "${userapikey}" -a ! -z "${recipients}" -a ! -z "${message}" -a ! -z "${title}" ]
464 then
463 - #https://docs.pushbullet.com/#create-push priority=-2
464 - for user in ${userapikeys}
465 + #https://docs.pushbullet.com/#create-push
466 + for user in ${recipients}
467 do
468 httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
467 - -u ""$user"": \
469 + -u "$userapikey": \
470 -d type="note" \
471 + --data-urlencode email="${user}" \
472 --data-urlencode body="${message}" \
473 --data-urlencode title="${title}" \
474 "https://api.pushbullet.com/v2/pushes"
475 )
476 +
477 if [ "${httpcode}" == "200" ]
478 then
479 echo >&2 "${me}: Sent pushbullet notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
@@ -711,10 +715,10 @@ ${alarm}
715 Severity: ${severity}
716 Chart: ${chart}
717 Family: ${family}
714 -To view NetData: ${goto_url}
718 +To View Netdata go to: ${goto_url}
719 The source of this alarm is line ${src}"
720 pushbullet_title="${status} at ${host} ${status_message} - ${name//_/ } - ${chart}}"
717 -send_pushbullet "${DEFAULT_RECIPIENT_PUSHBULLET}" "$pushbullet_message" "$pushbullet_title"
721 +send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${to_pushbullet}" "$pushbullet_message" "$pushbullet_title"
722
723 SENT_PUSHBULLET=$?
724
@@ -832,7 +836,7 @@ SENT_EMAIL=$?
836 # let netdata know
837
838 # we did send something
835 -[ ${SENT_EMAIL} -eq 0 -o ${SENT_PUSHOVER} -eq 0 -o ${SENT_TELEGRAM} -eq 0 -o ${SENT_SLACK} -eq 0 ] && exit 0
839 +[ ${SENT_EMAIL} -eq 0 -o ${SENT_PUSHOVER} -eq 0 -o ${SENT_TELEGRAM} -eq 0 -o ${SENT_SLACK} -eq 0 -o ${SENT_PUSHBULLET} -eq 0 ] && exit 0
840
841 # we did not send anything
842 exit 1