]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/alarm-notify.sh
hipchat: simplify server definition
[netdata.git] / plugins.d / alarm-notify.sh
index 2b385f7f44f1d703a3a37e4beee1d231400adb8a..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
@@ -1284,12 +1284,13 @@ SENT_PD=$?
 # -----------------------------------------------------------------------------
 # send hipchat message
 
-send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" "\
-<b>${alarm}</b> ${info_html}<br/>&nbsp;\
-${host} <b>${severity}</b> on chart <b>${chart}</b><br/> (family <b>${family}</b><br/>)\
-Time <b>${date}${raised_for_html}</b><br/>\
-<a href=\\\"${goto_url}\\\">View Netdata</a>\
-(the source of this alarm is line ${src})\
+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/> \
+<b>${date}${raised_for_html}</b><br/> \
+<a href=\\\"${goto_url}\\\">View netdata dashboard</a> \
+(source of alarm ${src}) \
 "
 
 SENT_HIPCHAT=$?