@cryptotaxi247 / netdata-1 / commits / 25a42b1b3

adding better channel integration based on @ktsaou advices

Guillaume Hospital committed Jul 10, 2018 at 13:32 UTC 25a42b1b3c16241a044a68291767ed36ec0583f3
2 files changed +10 -4
conf.d/health_alarm_notify.conf
+5 -2
@@ -343,13 +343,16 @@ DEFAULT_RECIPIENT_SLACK=""
343 # enable/disable sending team notifications
344 SEND_MSTEAM="YES"
345
346 -MSTEAM_WEBHOOK_URL=""
347 -
346 # if a role's recipients are not configured, a notification will be send to
347 # this slack channel (empty = do not send a notification for unconfigured
348 # roles):
349 # For team the channel name is encoded in the URI after ....IncomingWebhook/___/.....
350 +# This value will be replaced in the webhook value to publish to several channels in a same Team.
351 +# In order to get it working properly, you have to replace the value between [] ....IncomingWebhook/[___]/..... by "CHANNEL" string.
352 DEFAULT_RECIPIENT_MSTEAM=""
353 +# Based on the way MS Teams is working, put the differents channels here like : "CHANNEL1 CHANNEL2 ..."
354 +# AT LEAST ONE CHANNEL IS MANDATORY
355 +MSTEAM_WEBHOOK_URL=""
356
357 # Define the default color scheme for alert to MS Team - icon and color
358 # Icons - go to https://emojipedia.org/bomb/
plugins.d/alarm-notify.sh
+5 -2
@@ -1378,7 +1378,7 @@ send_msteam() {
1378 *) icon="${MSTEAM_ICON_DEFAULT}" && color="${MSTEAM_COLOR_DEFAULT}";;
1379 esac
1380
1381 - for channels in ${channels}
1381 + for channel in ${channels}
1382 do
1383 ## More details are available here regarding the payload syntax options : https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
1384 ## Online designer : https://acdesignerbeta.azurewebsites.net/
@@ -1394,7 +1394,7 @@ send_msteam() {
1394 "@type": "OpenUri",
1395 "name": "Netdata",
1396 "targets": [
1397 - { "os": "default", "uri": "http://$(hostname -f):19999" }
1397 + { "os": "default", "uri": "${goto_url}" }
1398 ]
1399 }
1400 ]
@@ -1402,6 +1402,9 @@ send_msteam() {
1402 EOF
1403 )"
1404
1405 + # Replacing in the webhook CHANNEL string by the MS Teams channel name from conf file.
1406 + webhook=`echo $1 | sed 's/CHANNEL/'${channel}'/g'`
1407 +
1408 httpcode=$(docurl -H "Content-Type: application/json" -d "${payload}" "${webhook}")
1409
1410 if [ "${httpcode}" = "200" ]