summaryrefslogtreecommitdiffstats
path: root/health/notifications
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-05-19 12:33:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-05-19 12:33:27 +0000
commit841395dd16f470e3c051a0a4fff5b91efc983c30 (patch)
tree4115f6eedcddda75067130b80acaff9e51612f49 /health/notifications
parentAdding upstream version 1.30.1. (diff)
downloadnetdata-841395dd16f470e3c051a0a4fff5b91efc983c30.tar.xz
netdata-841395dd16f470e3c051a0a4fff5b91efc983c30.zip
Adding upstream version 1.31.0.upstream/1.31.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/notifications')
-rw-r--r--health/notifications/Makefile.am1
-rwxr-xr-xhealth/notifications/alarm-notify.sh.in78
-rwxr-xr-xhealth/notifications/health_alarm_notify.conf60
-rw-r--r--health/notifications/msteams/Makefile.inc12
-rw-r--r--health/notifications/msteams/README.md45
5 files changed, 148 insertions, 48 deletions
diff --git a/health/notifications/Makefile.am b/health/notifications/Makefile.am
index e6b42138e..46a6e472c 100644
--- a/health/notifications/Makefile.am
+++ b/health/notifications/Makefile.am
@@ -35,6 +35,7 @@ include hangouts/Makefile.inc
include irc/Makefile.inc
include kavenegar/Makefile.inc
include messagebird/Makefile.inc
+include msteams/Makefile.inc
include opsgenie/Makefile.inc
include pagerduty/Makefile.inc
include pushbullet/Makefile.inc
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index bf6c02816..9a3a80ad6 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -165,7 +165,7 @@ pd
fleep
syslog
custom
-msteam
+msteams
kavenegar
prowl
irc
@@ -300,8 +300,11 @@ done
# slack configs
SLACK_WEBHOOK_URL=
-# Microsoft Team configs
-MSTEAM_WEBHOOK_URL=
+# Microsoft Teams configs
+MSTEAMS_WEBHOOK_URL=
+
+# Legacy Microsoft Teams configs for backwards compatability:
+declare -A role_recipients_msteam
# rocketchat configs
ROCKETCHAT_WEBHOOK_URL=
@@ -431,6 +434,38 @@ if [ "${use_fqdn}" = "YES" ] && [ "${host}" = "$(hostname -s 2>/dev/null)" ]; th
host="$(hostname -f 2>/dev/null)"
fi
+
+# -----------------------------------------------------------------------------
+# migrate old Microsoft Teams configuration keys after loading configuration
+
+msteams_migration() {
+ SEND_MSTEAMS=${SEND_MSTEAM:-$SEND_MSTEAMS}
+ unset -v SEND_MSTEAM
+ DEFAULT_RECIPIENT_MSTEAMS=${DEFAULT_RECIPIENT_MSTEAM:-$DEFAULT_RECIPIENT_MSTEAMS}
+ MSTEAMS_WEBHOOK_URL=${MSTEAM_WEBHOOK_URL:-$MSTEAMS_WEBHOOK_URL}
+ MSTEAMS_ICON_DEFAULT=${MSTEAM_ICON_DEFAULT:-$MSTEAMS_ICON_DEFAULT}
+ MSTEAMS_ICON_CLEAR=${MSTEAM_ICON_CLEAR:-$MSTEAMS_ICON_CLEAR}
+ MSTEAMS_ICON_WARNING=${MSTEAM_ICON_WARNING:-$MSTEAMS_ICON_WARNING}
+ MSTEAMS_ICON_CRITICAL=${MSTEAM_ICON_CRITICAL:-$MSTEAMS_ICON_CRITICAL}
+ MSTEAMS_COLOR_DEFAULT=${MSTEAM_COLOR_DEFAULT:-$MSTEAMS_COLOR_DEFAULT}
+ MSTEAMS_COLOR_CLEAR=${MSTEAM_COLOR_CLEAR:-$MSTEAMS_COLOR_CLEAR}
+ MSTEAMS_COLOR_WARNING=${MSTEAM_COLOR_WARNING:-$MSTEAMS_COLOR_WARNING}
+ MSTEAMS_COLOR_CRITICAL=${MSTEAM_COLOR_CRITICAL:-$MSTEAMS_COLOR_CRITICAL}
+
+ # migrate role specific recipients:
+ for key in "${!role_recipients_msteam[@]}"; do
+ # Disable check, if role_recipients_msteams is ever used:
+ # The role_recipients_$method are created and used programmatically
+ # by iterating over $methods. shellcheck therefore doesn't realize
+ # that role_recipients_msteams is actually used in the block
+ # "find the recipients' addresses per method".
+ # shellcheck disable=SC2034
+ role_recipients_msteams["$key"]="${role_recipients_msteam["$key"]}"
+ done
+}
+
+msteams_migration
+
# -----------------------------------------------------------------------------
# filter a recipient based on alarm event severity
@@ -553,8 +588,8 @@ filter_recipient_by_criticality() {
# check stackpulse
[ -z "${STACKPULSE_WEBHOOK}" ] && SEND_STACKPULSE="NO"
-# check msteam
-[ -z "${MSTEAM_WEBHOOK_URL}" ] && SEND_MSTEAM="NO"
+# check msteams
+[ -z "${MSTEAMS_WEBHOOK_URL}" ] && SEND_MSTEAMS="NO"
# check pd
[ -z "${DEFAULT_RECIPIENT_PD}" ] && SEND_PD="NO"
@@ -562,6 +597,9 @@ filter_recipient_by_criticality() {
# check prowl
[ -z "${DEFAULT_RECIPIENT_PROWL}" ] && SEND_PROWL="NO"
+# check custom
+[ -z "${DEFAULT_RECIPIENT_CUSTOM}" ] && SEND_CUSTOM="NO"
+
if [ "${SEND_PUSHOVER}" = "YES" ] ||
[ "${SEND_SLACK}" = "YES" ] ||
[ "${SEND_ROCKETCHAT}" = "YES" ] ||
@@ -581,7 +619,7 @@ if [ "${SEND_PUSHOVER}" = "YES" ] ||
[ "${SEND_HANGOUTS}" = "YES" ] ||
[ "${SEND_MATRIX}" = "YES" ] ||
[ "${SEND_CUSTOM}" = "YES" ] ||
- [ "${SEND_MSTEAM}" = "YES" ] ||
+ [ "${SEND_MSTEAMS}" = "YES" ] ||
[ "${SEND_DYNATRACE}" = "YES" ] ||
[ "${SEND_STACKPULSE}" = "YES" ] ||
[ "${SEND_OPSGENIE}" = "YES" ]; then
@@ -595,7 +633,7 @@ if [ "${SEND_PUSHOVER}" = "YES" ] ||
SEND_PUSHBULLET="NO"
SEND_TELEGRAM="NO"
SEND_SLACK="NO"
- SEND_MSTEAM="NO"
+ SEND_MSTEAMS="NO"
SEND_ROCKETCHAT="NO"
SEND_ALERTA="NO"
SEND_PD="NO"
@@ -750,7 +788,7 @@ for method in "${SEND_EMAIL}" \
"${SEND_AWSSNS}" \
"${SEND_SYSLOG}" \
"${SEND_SMS}" \
- "${SEND_MSTEAM}" \
+ "${SEND_MSTEAMS}" \
"${SEND_DYNATRACE}" \
"${SEND_STACKPULSE}" \
"${SEND_OPSGENIE}" ; do
@@ -1288,22 +1326,22 @@ send_telegram() {
# -----------------------------------------------------------------------------
# Microsoft Team sender
-send_msteam() {
+send_msteams() {
local webhook="${1}" channels="${2}" httpcode sent=0 channel color payload
- [ "${SEND_MSTEAM}" != "YES" ] && return 1
+ [ "${SEND_MSTEAMS}" != "YES" ] && return 1
case "${status}" in
- WARNING) icon="${MSTEAM_ICON_WARNING}" && color="${MSTEAM_COLOR_WARNING}" ;;
- CRITICAL) icon="${MSTEAM_ICON_CRITICAL}" && color="${MSTEAM_COLOR_CRITICAL}" ;;
- CLEAR) icon="${MSTEAM_ICON_CLEAR}" && color="${MSTEAM_COLOR_CLEAR}" ;;
- *) icon="${MSTEAM_ICON_DEFAULT}" && color="${MSTEAM_COLOR_DEFAULT}" ;;
+ WARNING) icon="${MSTEAMS_ICON_WARNING}" && color="${MSTEAMS_COLOR_WARNING}" ;;
+ CRITICAL) icon="${MSTEAMS_ICON_CRITICAL}" && color="${MSTEAMS_COLOR_CRITICAL}" ;;
+ CLEAR) icon="${MSTEAMS_ICON_CLEAR}" && color="${MSTEAMS_COLOR_CLEAR}" ;;
+ *) icon="${MSTEAMS_ICON_DEFAULT}" && color="${MSTEAMS_COLOR_DEFAULT}" ;;
esac
for channel in ${channels}; do
## More details are available here regarding the payload syntax options : https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
- ## Online designer : https://acdesignerbeta.azurewebsites.net/
+ ## Online designer : https://adaptivecards.io/designer/
payload="$(
cat <<EOF
{
@@ -2346,13 +2384,13 @@ send_hangouts "${to_hangouts}"
SENT_HANGOUTS=$?
# -----------------------------------------------------------------------------
-# send the Microsoft notification
+# send the Microsoft Teams notification
-# Microsoft team aggregates posts from the same username
+# Microsoft teams aggregates posts from the same username
# so we use "${host} ${status}" as the bot username, to make them diff
-send_msteam "${MSTEAM_WEBHOOK_URL}" "${to_msteam}"
-SENT_MSTEAM=$?
+send_msteams "${MSTEAMS_WEBHOOK_URL}" "${to_msteams}"
+SENT_MSTEAMS=$?
# -----------------------------------------------------------------------------
# send the rocketchat notification
@@ -2769,7 +2807,7 @@ for state in "${SENT_EMAIL}" \
"${SENT_MATRIX}" \
"${SENT_SYSLOG}" \
"${SENT_SMS}" \
- "${SENT_MSTEAM}" \
+ "${SENT_MSTEAMS}" \
"${SENT_DYNATRACE}" \
"${SENT_STACKPULSE}" \
"${SENT_OPSGENIE}"; do
diff --git a/health/notifications/health_alarm_notify.conf b/health/notifications/health_alarm_notify.conf
index ae23180bb..e851a530c 100755
--- a/health/notifications/health_alarm_notify.conf
+++ b/health/notifications/health_alarm_notify.conf
@@ -19,7 +19,7 @@
# - notifications to Amazon SNS topics (aws.amazon.com)
# - messages to your irc channel on your selected network
# - messages to a local or remote syslog daemon
-# - message to Microsoft Team (through webhook)
+# - message to Microsoft Teams (through webhook)
# - message to Rocket.Chat (through webhook)
# - message to Google Hangouts Chat (through webhook)
#
@@ -464,38 +464,42 @@ SLACK_WEBHOOK_URL=""
DEFAULT_RECIPIENT_SLACK=""
#------------------------------------------------------------------------------
-# Microsoft Team (office.com) global notification options
-# More details are available here regarding the payload syntax options : https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
-# Online designer : https://acdesignerbeta.azurewebsites.net/
+# Microsoft Teams (office.com) global notification options
+# More details are available here regarding the payload syntax options:
+# https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
+# Online designer : https://adaptivecards.io/designer/
# multiple recipients can be given like this:
# "CHANNEL1 CHANNEL2 ..."
-# enable/disable sending team notifications
-SEND_MSTEAM="YES"
+# enable/disable sending teams notifications
+SEND_MSTEAMS="YES"
+
+# In Microsoft Teams the channel name is encoded in the URI after
+# .../IncomingWebhook/...
+# You have to replace the encoded channel name by the placeholder `CHANNEL`
+# in `MSTEAMS_WEBHOOK_URL`. The placeholder `CHANNEL` will be replaced by the
+# actual encoded channel name before sending the notification.
+MSTEAMS_WEBHOOK_URL=""
# if a role's recipients are not configured, a notification will be send to
-# this slack channel (empty = do not send a notification for unconfigured
+# this Teams channel (empty = do not send a notification for unconfigured
# roles):
-# For team the channel name is encoded in the URI after ....IncomingWebhook/___/.....
-# This value will be replaced in the webhook value to publish to several channels in a same Team.
-# In order to get it working properly, you have to replace the value between [] ....IncomingWebhook/[___]/..... by "CHANNEL" string.
-DEFAULT_RECIPIENT_MSTEAM=""
-# Based on the way MS Teams is working, put the different channels here like : "CHANNEL1 CHANNEL2 ..."
+# Put the different encoded channel names here like : "CHANNEL1 CHANNEL2 ..."
# AT LEAST ONE CHANNEL IS MANDATORY
-MSTEAM_WEBHOOK_URL=""
+DEFAULT_RECIPIENT_MSTEAMS=""
-# Define the default color scheme for alert to MS Team - icon and color
+# Define the default color scheme for alert to MS Teams - icon and color
# Icons - go to https://emojipedia.org/bomb/
-MSTEAM_ICON_DEFAULT="♡"
-MSTEAM_ICON_CLEAR="💚"
-MSTEAM_ICON_WARNING="⚠️"
-MSTEAM_ICON_CRITICAL="🔥"
+MSTEAMS_ICON_DEFAULT="♡"
+MSTEAMS_ICON_CLEAR="💚"
+MSTEAMS_ICON_WARNING="⚠️"
+MSTEAMS_ICON_CRITICAL="🔥"
# Colors
-MSTEAM_COLOR_DEFAULT="0076D7"
-MSTEAM_COLOR_CLEAR="65A677"
-MSTEAM_COLOR_WARNING="FFA500"
-MSTEAM_COLOR_CRITICAL="D93F3C"
+MSTEAMS_COLOR_DEFAULT="0076D7"
+MSTEAMS_COLOR_CLEAR="65A677"
+MSTEAMS_COLOR_WARNING="FFA500"
+MSTEAMS_COLOR_CRITICAL="D93F3C"
#------------------------------------------------------------------------------
@@ -955,7 +959,7 @@ role_recipients_awssns[sysadmin]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[sysadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
-role_recipients_msteam[sysadmin]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_msteams[sysadmin]="${DEFAULT_RECIPIENT_MSTEAMS}"
role_recipients_rocketchat[sysadmin]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
@@ -1010,7 +1014,7 @@ role_recipients_awssns[domainadmin]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[domainadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
-role_recipients_msteam[domainadmin]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_msteams[domainadmin]="${DEFAULT_RECIPIENT_MSTEAMS}"
role_recipients_rocketchat[domainadmin]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
@@ -1068,7 +1072,7 @@ role_recipients_awssns[dba]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[dba]="${DEFAULT_RECIPIENT_CUSTOM}"
-role_recipients_msteam[dba]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_msteams[dba]="${DEFAULT_RECIPIENT_MSTEAMS}"
role_recipients_rocketchat[dba]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
@@ -1126,7 +1130,7 @@ role_recipients_awssns[webmaster]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[webmaster]="${DEFAULT_RECIPIENT_CUSTOM}"
-role_recipients_msteam[webmaster]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_msteams[webmaster]="${DEFAULT_RECIPIENT_MSTEAMS}"
role_recipients_rocketchat[webmaster]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
@@ -1184,7 +1188,7 @@ role_recipients_awssns[proxyadmin]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[proxyadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
-role_recipients_msteam[proxyadmin]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_msteams[proxyadmin]="${DEFAULT_RECIPIENT_MSTEAMS}"
role_recipients_rocketchat[proxyadmin]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
@@ -1240,7 +1244,7 @@ role_recipients_awssns[sitemgr]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[sitemgr]="${DEFAULT_RECIPIENT_CUSTOM}"
-role_recipients_msteam[sitemgr]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_msteams[sitemgr]="${DEFAULT_RECIPIENT_MSTEAMS}"
role_recipients_rocketchat[sitemgr]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
diff --git a/health/notifications/msteams/Makefile.inc b/health/notifications/msteams/Makefile.inc
new file mode 100644
index 000000000..f4c6995b8
--- /dev/null
+++ b/health/notifications/msteams/Makefile.inc
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# THIS IS NOT A COMPLETE Makefile
+# IT IS INCLUDED BY ITS PARENT'S Makefile.am
+# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT
+
+# install these files
+dist_noinst_DATA += \
+ msteams/README.md \
+ msteams/Makefile.inc \
+ $(NULL)
+
diff --git a/health/notifications/msteams/README.md b/health/notifications/msteams/README.md
new file mode 100644
index 000000000..3ff5de68d
--- /dev/null
+++ b/health/notifications/msteams/README.md
@@ -0,0 +1,45 @@
+<!--
+---
+title: "Microsoft Teams"
+custom_edit_url: https://github.com/netdata/netdata/edit/master/health/notifications/msteams/README.md
+---
+-->
+
+# Microsoft Teams
+
+This is what you will get:
+![image](https://user-images.githubusercontent.com/1122372/92710359-0385e680-f358-11ea-8c52-f366a4fb57dd.png)
+
+You need:
+
+1. The **incoming webhook URL** as given by Microsoft Teams. You can use the same on all your Netdata servers (or you can have multiple if you like - your decision).
+2. One or more channels to post the messages to.
+
+In Microsoft Teams the channel name is encoded in the URI after `/IncomingWebhook/` (for clarity the marked with `[]` in the following example): `https://outlook.office.com/webhook/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/IncomingWebhook/[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX`
+
+You have to replace the encoded channel name by the placeholder `CHANNEL` in `MSTEAMS_WEBHOOK_URL`. The placeholder `CHANNEL` will be replaced by the actual encoded channel name before sending the notification. This makes it possible to publish to several channels in the same team.
+
+The encoded channel name must then be added to `DEFAULT_RECIPIENTS_MSTEAMS` or to one of the specific variables `role_recipients_msteams[]`. **At least one channel is mandatory for `DEFAULT_RECIPIENTS_MSTEAMS`.**
+
+Set the webhook and the recipients in `/etc/netdata/health_alarm_notify.conf` (to edit it on your system run `/etc/netdata/edit-config health_alarm_notify.conf`), like this:
+
+```
+SEND_MSTEAMS="YES"
+
+MSTEAMS_WEBHOOK_URL="https://outlook.office.com/webhook/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX@XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/IncomingWebhook/CHANNEL/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
+
+DEFAULT_RECIPIENT_MSTEAMS="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+```
+
+You can define multiple recipients by listing the encoded channel names like this: `XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY`.
+This example will send the alarm to the two channels specified by their encoded channel names.
+
+You can give different recipients per **role** using these (in the same file):
+
+```
+role_recipients_msteams[sysadmin]="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+role_recipients_msteams[dba]="YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
+role_recipients_msteams[webmaster]="ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
+```
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fhealth%2Fnotifications%2Fmsteams%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>)