hipchat: simplify server definition
Manuel Frei committed
Feb 23, 2017 at 00:22 UTC
da855a2eab3455f413a715271aa4aa2978d7c6a8
2 files changed
+8
-21
conf.d/health_alarm_notify.conf
+2
-3
@@ -258,9 +258,8 @@ DEFAULT_RECIPIENT_DISCORD=""
258
# enable/disable sending hipchat notifications
259
SEND_HIPCHAT="YES"
260
261
-# if HipChat Server (self-hosted) is used set fqdn here
262
-# ex. hipchat.example.com (empty = use HipChat Cloud)
263
-HIPCHAT_CUSTOM_SERVER=""
261
+# define hipchat server
262
+HIPCHAT_SERVER="api.hipchat.com"
263
264
# api.hipchat.com authorization token
265
# Without this, netdata cannot send hipchat notifications.
plugins.d/alarm-notify.sh
+6
-18
@@ -214,7 +214,7 @@ DEFAULT_RECIPIENT_TWILIO=
214
declare -A role_recipients_twilio=()
215
216
# hipchat configs
217
-HIPCHAT_CUSTOM_SERVER=
217
+HIPCHAT_SERVER=
218
HIPCHAT_AUTH_TOKEN=
219
DEFAULT_RECIPIENT_HIPCHAT=
220
declare -A role_recipients_hipchat=()
@@ -853,15 +853,9 @@ send_twilio() {
853
# hipchat sender
854
855
send_hipchat() {
856
- local hipchat_server="${1}" authtoken="${2}" recipients="${3}" message="${4}" httpcode sent=0 room color sender msg_format notify
856
+ local authtoken="${1}" recipients="${2}" message="${3}" httpcode sent=0 room color sender msg_format notify
857
858
- # Use HipChat Cloud if no server specified
859
- if [ -z "${hipchat_server}" ]
860
- then
861
- hipchat_server="api.hipchat.com"
862
- fi
863
-
864
- if [ "${SEND_HIPCHAT}" = "YES" -a ! -z "${hipchat_server}" -a ! -z "${authtoken}" -a ! -z "${recipients}" -a ! -z "${message}" ]
858
+ if [ "${SEND_HIPCHAT}" = "YES" -a ! -z "${HIPCHAT_SERVER}" -a ! -z "${authtoken}" -a ! -z "${recipients}" -a ! -z "${message}" ]
859
then
860
# A label to be shown in addition to the sender's name
861
# Valid length range: 0 - 64.
@@ -869,13 +863,7 @@ send_hipchat() {
863
864
# Valid values: html, text.
865
# Defaults to 'html'.
872
- msg_format="text"
873
-
874
- # Detect html messages
875
- if echo "${message}" | tr -d '\n' | grep -q "<[a-z]\+>.*</[a-z]\+>\|<[a-z]\+/>"
876
- then
877
- msg_format="html"
878
- fi
866
+ msg_format="html"
867
868
# Background color for message. Valid values: yellow, green, red, purple, gray, random. Defaults to 'yellow'.
869
case "${status}" in
@@ -896,7 +884,7 @@ send_hipchat() {
884
-H "Content-type: application/json" \
885
-H "Authorization: Bearer ${authtoken}" \
886
-d "{\"color\": \"${color}\", \"from\": \"${netdata}\", \"message_format\": \"${msg_format}\", \"message\": \"${message}\", \"notify\": \"${notify}\"}" \
899
- "https://${hipchat_server}/v2/room/${room}/notification")
887
+ "https://${HIPCHAT_SERVER}/v2/room/${room}/notification")
888
889
if [ "${httpcode}" == "204" ]
890
then
@@ -1296,7 +1284,7 @@ SENT_PD=$?
1284
# -----------------------------------------------------------------------------
1285
# send hipchat message
1286
1299
-send_hipchat "${HIPCHAT_CUSTOM_SERVER}" "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
1287
+send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
1288
${host} ${status_message}<br/> \
1289
<b>${alarm}</b> ${info_html}<br/> \
1290
<b>${chart}</b> (family <b>${family}</b>)<br/> \