]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/alarm-notify.sh
hipchat: detect html messages
[netdata.git] / plugins.d / alarm-notify.sh
index bd2b94b148110d3772cfb4a7f2b163c360bf776a..87ba84d3d8a9ed9725c04e235153f5c29776dfe4 100755 (executable)
@@ -865,6 +865,12 @@ send_hipchat() {
         # 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
+
         # Background color for message. Valid values: yellow, green, red, purple, gray, random. Defaults to 'yellow'.
         case "${status}" in
             WARNING)  color="yellow" ;;
@@ -1284,13 +1290,13 @@ SENT_PD=$?
 # -----------------------------------------------------------------------------
 # send hipchat message
 
-send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" "\
-${host} ${status_message}<br/>\
-<b>${alarm}</b> ${info_html}<br/>\
-<b>${chart}</b> (family <b>${family}</b> )\
-<b>${date}${raised_for_html}</b><br/>\
+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})\
+(source of alarm ${src}) \
 "
 
 SENT_HIPCHAT=$?