@cryptotaxi247 / netdata-1 / commits / 1ede849b6

Modified the code to be compliant with latest pushbullet API Added proper line breaks to the pushbullet message Fixed a typo in the configuration file Added a script to test alarms

Modified the code to be compliant with latest pushbullet API Added proper line breaks to the pushbullet message Fixed a typo in the configuration file Added a script to test alarms

Tiago Peralta committed Oct 8, 2016 at 04:24 UTC 1ede849b65ed1e9f486c6e8081029e061f662b15
4 files changed +19 -17
conf.d/health_alarm_notify.conf
+1 -1
@@ -132,7 +132,7 @@ SEND_PUSHBULLET="YES"
132 # to that address instead
133
134 # Without an access token, netdata cannot send pushbullet notifications.
135 -PUSBULLET_ACCESS_TOKEN=""
135 +PUSHBULLET_ACCESS_TOKEN=""
136 DEFAULT_RECIPIENT_PUSHBULLET=""
137
138 ###############################################################################
plugins.d/Makefile.am
+1
@@ -10,6 +10,7 @@ dist_plugins_DATA = \
10 dist_plugins_SCRIPTS = \
11 alarm-email.sh \
12 alarm-notify.sh \
13 + alarm-test.sh \
14 cgroup-name.sh \
15 charts.d.dryrun-helper.sh \
16 charts.d.plugin \
plugins.d/alarm-notify.sh
+14 -16
@@ -459,20 +459,21 @@ send_pushover() {
459
460 send_pushbullet() {
461 local userapikey="${1}" recipients="${2}" message="${3}" title="${4}" httpcode sent=0 user
462 -
462 if [ "${SEND_PUSHBULLET}" = "YES" -a ! -z "${userapikey}" -a ! -z "${recipients}" -a ! -z "${message}" -a ! -z "${title}" ]
463 then
464 #https://docs.pushbullet.com/#create-push
465 for user in ${recipients}
466 do
467 httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
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 - )
468 + --header 'Access-Token: '$userapikey'' \
469 + --header 'Content-Type: application/json' \
470 + --data-binary @<(cat <<EOF
471 + {"title": "${title}",
472 + "type": "note",
473 + "email": "${user}",
474 + "body": "$( echo -n ${message})"}
475 +EOF
476 + ) "https://api.pushbullet.com/v2/pushes" -X POST)
477
478 if [ "${httpcode}" == "200" ]
479 then
@@ -489,8 +490,6 @@ send_pushbullet() {
490 return 1
491 }
492
492 -
493 -
493 # -----------------------------------------------------------------------------
494 # telegram sender
495
@@ -710,12 +709,11 @@ SENT_PUSHOVER=$?
709 # -----------------------------------------------------------------------------
710 # send the pushbullet notification
711
713 -pushbullet_message="
714 -${alarm}
715 -Severity: ${severity}
716 -Chart: ${chart}
717 -Family: ${family}
718 -To View Netdata go to: ${goto_url}
712 +pushbullet_message="${alarm} \n
713 +Severity: ${severity} \n
714 +Chart: ${chart} \n
715 +Family: ${family} \n
716 +To View Netdata go to: ${goto_url} \n
717 The source of this alarm is line ${src}"
718 pushbullet_title="${status} at ${host} ${status_message} - ${name//_/ } - ${chart}}"
719 send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${to_pushbullet}" "$pushbullet_message" "$pushbullet_title"
plugins.d/alarm-test.sh new
+3
@@ -0,0 +1,3 @@
1 +#!/usr/bin/env bash
2 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 +$($DIR/alarm-notify.sh 'sysadmin' 'DummyAlarm' '1475604061' '1475604028' '3' '1475604369' '10min_cpu_usage' 'system.cpu' 'cpu' 'WARNING' 'CLEAR' '83' '80' '2@/etc/netdata/health.d/cpu.conf' '360' '0' '%' 'average cpu utilization for the last 45 minutes'})