@cryptotaxi247 / netdata-1 / commits / 75228cd7d

hipchat: add support for HipChat Server

Manuel Frei committed Feb 22, 2017 at 22:58 UTC 75228cd7d492c7aa04d2efcaab59004eb458397b
2 files changed +15 -5
conf.d/health_alarm_notify.conf
+4
@@ -258,6 +258,10 @@ 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=""
264 +
265 # api.hipchat.com authorization token
266 # Without this, netdata cannot send hipchat notifications.
267 HIPCHAT_AUTH_TOKEN=""
plugins.d/alarm-notify.sh
+11 -5
@@ -214,6 +214,7 @@ DEFAULT_RECIPIENT_TWILIO=
214 declare -A role_recipients_twilio=()
215
216 # hipchat configs
217 +HIPCHAT_CUSTOM_SERVER=
218 HIPCHAT_AUTH_TOKEN=
219 DEFAULT_RECIPIENT_HIPCHAT=
220 declare -A role_recipients_hipchat=()
@@ -852,11 +853,16 @@ send_twilio() {
853 # hipchat sender
854
855 send_hipchat() {
855 - local authtoken="${1}" recipients="${2}" message="${3}" httpcode sent=0 room color sender msg_format notify
856 + local hipchat_server="${1}" authtoken="${2}" recipients="${3}" message="${4}" httpcode sent=0 room color sender msg_format notify
857
857 - if [ "${SEND_HIPCHAT}" = "YES" -a ! -z "${authtoken}" -a ! -z "${recipients}" -a ! -z "${message}" ]
858 - then
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}" ]
865 + then
866 # A label to be shown in addition to the sender's name
867 # Valid length range: 0 - 64.
868 sender="netdata"
@@ -890,7 +896,7 @@ send_hipchat() {
896 -H "Content-type: application/json" \
897 -H "Authorization: Bearer ${authtoken}" \
898 -d "{\"color\": \"${color}\", \"from\": \"${netdata}\", \"message_format\": \"${msg_format}\", \"message\": \"${message}\", \"notify\": \"${notify}\"}" \
893 - "https://api.hipchat.com/v2/room/${room}/notification")
899 + "https://${hipchat_server}/v2/room/${room}/notification")
900
901 if [ "${httpcode}" == "204" ]
902 then
@@ -1290,7 +1296,7 @@ SENT_PD=$?
1296 # -----------------------------------------------------------------------------
1297 # send hipchat message
1298
1293 -send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
1299 +send_hipchat "${HIPCHAT_CUSTOM_SERVER}" "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
1300 ${host} ${status_message}<br/> \
1301 <b>${alarm}</b> ${info_html}<br/> \
1302 <b>${chart}</b> (family <b>${family}</b>)<br/> \