]> arthur.barton.de Git - netdata.git/commitdiff
hipchat: simplify server definition
authorManuel Frei <frei.manu@gmail.com>
Wed, 22 Feb 2017 23:22:38 +0000 (00:22 +0100)
committerManuel Frei <frei.manu@gmail.com>
Wed, 22 Feb 2017 23:22:38 +0000 (00:22 +0100)
conf.d/health_alarm_notify.conf
plugins.d/alarm-notify.sh

index 7b3ad5ba898e7008c1f34da5e852215d5eaf7a75..23776b96aba4b25b45cb713db1ee8a50c0597c54 100644 (file)
@@ -258,9 +258,8 @@ DEFAULT_RECIPIENT_DISCORD=""
 # enable/disable sending hipchat notifications
 SEND_HIPCHAT="YES"
 
-# if HipChat Server (self-hosted) is used set fqdn here
-# ex. hipchat.example.com (empty = use HipChat Cloud)
-HIPCHAT_CUSTOM_SERVER=""
+# define hipchat server
+HIPCHAT_SERVER="api.hipchat.com"
 
 # api.hipchat.com authorization token
 # Without this, netdata cannot send hipchat notifications.
index 2387de2021bcbeffce1fc8030ee3675d1316d1c9..45d90563888d5dcd176154228c9c72275a317df6 100755 (executable)
@@ -214,7 +214,7 @@ DEFAULT_RECIPIENT_TWILIO=
 declare -A role_recipients_twilio=()
 
 # hipchat configs
-HIPCHAT_CUSTOM_SERVER=
+HIPCHAT_SERVER=
 HIPCHAT_AUTH_TOKEN=
 DEFAULT_RECIPIENT_HIPCHAT=
 declare -A role_recipients_hipchat=()
@@ -853,15 +853,9 @@ send_twilio() {
 # hipchat sender
 
 send_hipchat() {
-    local hipchat_server="${1}" authtoken="${2}" recipients="${3}" message="${4}" httpcode sent=0 room color sender msg_format notify
+    local authtoken="${1}" recipients="${2}" message="${3}" httpcode sent=0 room color sender msg_format notify
 
-    # Use HipChat Cloud if no server specified
-    if [ -z "${hipchat_server}" ]
-    then
-        hipchat_server="api.hipchat.com"
-    fi
-
-    if [ "${SEND_HIPCHAT}" = "YES" -a ! -z "${hipchat_server}" -a ! -z "${authtoken}" -a ! -z "${recipients}" -a ! -z "${message}" ]
+    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. 
@@ -869,13 +863,7 @@ send_hipchat() {
 
         # Valid values: html, text.
         # Defaults to 'html'.
-        msg_format="text"
-
-        # Detect html messages
-        if echo "${message}" | tr -d '\n' | grep -q "<[a-z]\+>.*</[a-z]\+>\|<[a-z]\+/>"
-        then
-            msg_format="html"
-        fi
+        msg_format="html"
 
         # Background color for message. Valid values: yellow, green, red, purple, gray, random. Defaults to 'yellow'.
         case "${status}" in
@@ -896,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://${hipchat_server}/v2/room/${room}/notification")
+                    "https://${HIPCHAT_SERVER}/v2/room/${room}/notification")
  
             if [ "${httpcode}" == "204" ]
             then
@@ -1296,7 +1284,7 @@ SENT_PD=$?
 # -----------------------------------------------------------------------------
 # send hipchat message
 
-send_hipchat "${HIPCHAT_CUSTOM_SERVER}" "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
+send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
 ${host} ${status_message}<br/> \
 <b>${alarm}</b> ${info_html}<br/> \
 <b>${chart}</b> (family <b>${family}</b>)<br/> \