]> arthur.barton.de Git - netdata.git/commitdiff
Merge branch 'master' into ab-debian
authorAlexander Barton <alex@barton.de>
Fri, 24 Feb 2017 23:27:12 +0000 (00:27 +0100)
committerAlexander Barton <alex@barton.de>
Fri, 24 Feb 2017 23:27:12 +0000 (00:27 +0100)
* master:
  hipchat: simplify server definition
  hipchat: add support for HipChat Server
  hipchat: detect html messages

conf.d/health_alarm_notify.conf
plugins.d/alarm-notify.sh

index e8e44d73f464691b611f7c609ac46fe0c118ca8a..23776b96aba4b25b45cb713db1ee8a50c0597c54 100644 (file)
@@ -258,6 +258,9 @@ DEFAULT_RECIPIENT_DISCORD=""
 # enable/disable sending hipchat notifications
 SEND_HIPCHAT="YES"
 
+# define hipchat server
+HIPCHAT_SERVER="api.hipchat.com"
+
 # api.hipchat.com authorization token
 # Without this, netdata cannot send hipchat notifications.
 HIPCHAT_AUTH_TOKEN=""
index 997ff96aa65f248d774f41513640fe31c38ba6c1..45d90563888d5dcd176154228c9c72275a317df6 100755 (executable)
@@ -214,6 +214,7 @@ DEFAULT_RECIPIENT_TWILIO=
 declare -A role_recipients_twilio=()
 
 # hipchat configs
+HIPCHAT_SERVER=
 HIPCHAT_AUTH_TOKEN=
 DEFAULT_RECIPIENT_HIPCHAT=
 declare -A role_recipients_hipchat=()
@@ -854,16 +855,15 @@ send_twilio() {
 send_hipchat() {
     local authtoken="${1}" recipients="${2}" message="${3}" httpcode sent=0 room color sender msg_format notify
 
-    if [ "${SEND_HIPCHAT}" = "YES" -a ! -z "${authtoken}" -a ! -z "${recipients}" -a ! -z "${message}" ]
-        then
-
+    if [ "${SEND_HIPCHAT}" = "YES" -a ! -z "${HIPCHAT_SERVER}" -a ! -z "${authtoken}" -a ! -z "${recipients}" -a ! -z "${message}" ]
+    then
         # A label to be shown in addition to the sender's name
         # Valid length range: 0 - 64. 
         sender="netdata"
 
         # Valid values: html, text.
         # Defaults to 'html'.
-        msg_format="text"
+        msg_format="html"
 
         # Background color for message. Valid values: yellow, green, red, purple, gray, random. Defaults to 'yellow'.
         case "${status}" in
@@ -884,7 +884,7 @@ send_hipchat() {
                     -H "Content-type: application/json" \
                     -H "Authorization: Bearer ${authtoken}" \
                     -d "{\"color\": \"${color}\", \"from\": \"${netdata}\", \"message_format\": \"${msg_format}\", \"message\": \"${message}\", \"notify\": \"${notify}\"}" \
-                    "https://api.hipchat.com/v2/room/${room}/notification")
+                    "https://${HIPCHAT_SERVER}/v2/room/${room}/notification")
  
             if [ "${httpcode}" == "204" ]
             then