summaryrefslogtreecommitdiffstats
path: root/health/notifications
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-10-26 08:29:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-10-26 08:29:53 +0000
commitd608b19e0d3b3f4d84fcfcdd72bb7e64c86b6f01 (patch)
tree8c283d1c81d718e64d87d9a2d1132c89f3915939 /health/notifications
parentReleasing debian version 1.18.0-1. (diff)
downloadnetdata-d608b19e0d3b3f4d84fcfcdd72bb7e64c86b6f01.tar.xz
netdata-d608b19e0d3b3f4d84fcfcdd72bb7e64c86b6f01.zip
Merging upstream version 1.18.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/notifications')
-rw-r--r--health/notifications/Makefile.am3
-rwxr-xr-xhealth/notifications/alarm-notify.sh.in127
-rw-r--r--health/notifications/hangouts/Makefile.inc11
-rw-r--r--health/notifications/hangouts/README.md33
-rwxr-xr-xhealth/notifications/health_alarm_notify.conf41
5 files changed, 211 insertions, 4 deletions
diff --git a/health/notifications/Makefile.am b/health/notifications/Makefile.am
index e3970de04..efce90bda 100644
--- a/health/notifications/Makefile.am
+++ b/health/notifications/Makefile.am
@@ -31,6 +31,7 @@ include awssns/Makefile.inc
include discord/Makefile.inc
include email/Makefile.inc
include flock/Makefile.inc
+include hangouts/Makefile.inc
include irc/Makefile.inc
include kavenegar/Makefile.inc
include messagebird/Makefile.inc
@@ -44,4 +45,4 @@ include syslog/Makefile.inc
include telegram/Makefile.inc
include twilio/Makefile.inc
include web/Makefile.inc
-include custom/Makefile.inc \ No newline at end of file
+include custom/Makefile.inc
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index 509a8e88d..b56c67e65 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -33,6 +33,7 @@
# - syslog messages by @Ferroin
# - Microsoft Team notification by @tioumen
# - RocketChat notifications by @Hermsi1337 #3777
+# - Google Hangouts Chat notifications by @EnzoAkira and @hendrikhofstadt
# -----------------------------------------------------------------------------
# testing notifications
@@ -166,6 +167,7 @@ prowl
awssns
rocketchat
sms
+hangouts
"
# -----------------------------------------------------------------------------
@@ -359,6 +361,9 @@ IRC_NICKNAME=
IRC_REALNAME=
IRC_NETWORK=
+# hangouts configs
+declare -A HANGOUTS_WEBHOOK_URI
+
# load the stock and user configuration files
# these will overwrite the variables above
@@ -491,6 +496,9 @@ filter_recipient_by_criticality() {
# check irc
[ -z "${IRC_NETWORK}" ] && SEND_IRC="NO"
+# check hangouts
+[ ${#HANGOUTS_WEBHOOK_URI[@]} -eq 0 ] && SEND_HANGOUTS="NO"
+
# check fleep
#shellcheck disable=SC2153
{ [ -z "${FLEEP_SERVER}" ] || [ -z "${FLEEP_SENDER}" ]; } && SEND_FLEEP="NO"
@@ -511,6 +519,7 @@ if [ "${SEND_PUSHOVER}" = "YES" ] ||
[ "${SEND_KAFKA}" = "YES" ] ||
[ "${SEND_FLEEP}" = "YES" ] ||
[ "${SEND_PROWL}" = "YES" ] ||
+ [ "${SEND_HANGOUTS}" = "YES" ] ||
[ "${SEND_CUSTOM}" = "YES" ] ||
[ "${SEND_MSTEAM}" = "YES" ]; then
# if we need curl, check for the curl command
@@ -536,6 +545,7 @@ if [ "${SEND_PUSHOVER}" = "YES" ] ||
SEND_KAFKA="NO"
SEND_FLEEP="NO"
SEND_PROWL="NO"
+ SEND_HANGOUTS="NO"
SEND_CUSTOM="NO"
fi
fi
@@ -659,6 +669,7 @@ for method in "${SEND_EMAIL}" \
"${SEND_PROWL}" \
"${SEND_CUSTOM}" \
"${SEND_IRC}" \
+ "${SEND_HANGOUTS}" \
"${SEND_AWSSNS}" \
"${SEND_SYSLOG}" \
"${SEND_SMS}" \
@@ -1771,6 +1782,112 @@ send_sms() {
}
# -----------------------------------------------------------------------------
+# hangouts sender
+
+send_hangouts() {
+ local rooms="${1}" httpcode sent=0 room color payload webhook
+
+ [ "${SEND_HANGOUTS}" != "YES" ] && return 1
+
+ case "${status}" in
+ WARNING) color="#ffa700" ;;
+ CRITICAL) color="#d62d20" ;;
+ CLEAR) color="#008744" ;;
+ *) color="#777777" ;;
+ esac
+
+ for room in ${rooms}; do
+ if [ -z "${HANGOUTS_WEBHOOK_URI[$room]}" ] ; then
+ info "Can't send Hangouts notification for: ${host} ${chart}.${name} to room ${room}. HANGOUTS_WEBHOOK_URI[$room] not defined"
+ else
+ webhook="${HANGOUTS_WEBHOOK_URI[$room]}"
+ payload="$(
+ cat <<EOF
+ {
+ "cards": [
+ {
+ "header": {
+ "title": "Netdata on ${host}",
+ "imageUrl": "${images_base_url}/images/banner-icon-144x144.png",
+ "imageStyle": "IMAGE"
+ },
+ "sections": [
+ {
+ "header": "<b>${host}</b>",
+ "widgets": [
+ {
+ "keyValue": {
+ "topLabel": "Status Message",
+ "content": "<b>${status_message}</b>",
+ "contentMultiline": "true",
+ "iconUrl": "${image}",
+ "onClick": {
+ "openLink": {
+ "url": "${goto_url}"
+ }
+ }
+ }
+ },
+ {
+ "keyValue": {
+ "topLabel": "${chart} | ${family}",
+ "content": "<font color=${color}>${alarm}</font>",
+ "contentMultiline": "true"
+ }
+ }
+ ]
+ },
+ {
+ "widgets": [
+ {
+ "textParagraph": {
+ "text": "<font color=\"#0057e7\">@ ${date}\n<b>${info}</b></font>"
+ }
+ }
+ ]
+ },
+ {
+ "widgets": [
+ {
+ "buttons": [
+ {
+ "textButton": {
+ "text": "Go to ${host}",
+ "onClick": {
+ "openLink": {
+ "url": "${goto_url}"
+ }
+ }
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+EOF
+ )"
+
+ httpcode=$(docurl -H "Content-Type: application/json" -X POST -d "${payload}" "${webhook}")
+
+ if [ "${httpcode}" = "200" ]; then
+ info "sent hangouts notification for: ${host} ${chart}.${name} is ${status} to '${room}'"
+ sent=$((sent + 1))
+ else
+ error "failed to send hangouts notification for: ${host} ${chart}.${name} is ${status} to '${room}', with HTTP error code ${httpcode}."
+ fi
+ fi
+ done
+
+ [ ${sent} -gt 0 ] && return 0
+
+ return 1
+}
+
+# -----------------------------------------------------------------------------
# prepare the content of the notification
# the url to send the user on click
@@ -1889,6 +2006,15 @@ send_slack "${SLACK_WEBHOOK_URL}" "${to_slack}"
SENT_SLACK=$?
# -----------------------------------------------------------------------------
+# send the hangouts notification
+
+# hangouts aggregates posts from the same room
+# so we use "${host} ${status}" as the room, to make them diff
+
+send_hangouts "${to_hangouts}"
+SENT_HANGOUTS=$?
+
+# -----------------------------------------------------------------------------
# send the Microsoft notification
# Microsoft team aggregates posts from the same username
@@ -2270,6 +2396,7 @@ for state in "${SENT_EMAIL}" \
"${SENT_PUSHOVER}" \
"${SENT_TELEGRAM}" \
"${SENT_SLACK}" \
+ "${SENT_HANGOUTS}" \
"${SENT_ROCKETCHAT}" \
"${SENT_ALERTA}" \
"${SENT_FLOCK}" \
diff --git a/health/notifications/hangouts/Makefile.inc b/health/notifications/hangouts/Makefile.inc
new file mode 100644
index 000000000..835154fe8
--- /dev/null
+++ b/health/notifications/hangouts/Makefile.inc
@@ -0,0 +1,11 @@
+# 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 += \
+ hangouts/README.md \
+ hangouts/Makefile.inc \
+ $(NULL)
diff --git a/health/notifications/hangouts/README.md b/health/notifications/hangouts/README.md
new file mode 100644
index 000000000..25dccad61
--- /dev/null
+++ b/health/notifications/hangouts/README.md
@@ -0,0 +1,33 @@
+# Hangouts Chat
+
+This is what you will get:
+![Netdata on Hangouts](https://user-images.githubusercontent.com/1153921/66427166-47de6900-e9c8-11e9-8322-b4b03f084dc1.png)
+To receive notifications in Google Hangouts, you need the following in your Hangouts setup:
+
+1. One or more rooms
+2. An **incoming webhook** for each room
+
+How to create an incoming webhook:
+https://developers.google.com/hangouts/chat/how-tos/webhooks
+
+Set the webhook URIs and room names in `health_alarm_notify.conf`. To edit it on your system, run `/etc/netdata/edit-config health_alarm_notify.conf`):
+
+```
+#------------------------------------------------------------------------------
+# hangouts (google hangouts chat) global notification options
+# enable/disable sending hangouts notifications
+SEND_HANGOUTS="YES"
+# On Hangouts, in the room you choose, create an incoming webhook,
+# copy the link and paste it below and also identify the room name.
+# Without it, netdata cannot send hangouts notifications to that room.
+# HANGOUTS_WEBHOOK_URI[ROOM_NAME]="URLforroom1"
+HANGOUTS_WEBHOOK_URI[systems]="https://chat.googleapis.com/v1/spaces/AAAAXXXXXXX/..."
+HANGOUTS_WEBHOOK_URI[development]="https://chat.googleapis.com/v1/spaces/AAAAYYYYY/..."
+# if a DEFAULT_RECIPIENT_HANGOUTS are not configured,
+# notifications wouldn't be send to hangouts rooms.
+# DEFAULT_RECIPIENT_HANGOUTS="systems development|critical"
+DEFAULT_RECIPIENT_HANGOUTS="sysadmin devops alarms|critical"
+```
+You can define multiple rooms like this: `sysadmin devops alarms|critical`.
+
+The keywords `sysadmin`, `devops` and `alarms` are Hangouts rooms.
diff --git a/health/notifications/health_alarm_notify.conf b/health/notifications/health_alarm_notify.conf
index 60621df27..955dd25b5 100755
--- a/health/notifications/health_alarm_notify.conf
+++ b/health/notifications/health_alarm_notify.conf
@@ -21,6 +21,7 @@
# - messages to a local or remote syslog daemon
# - message to Microsoft Team (through webhook)
# - message to Rocket.Chat (through webhook)
+# - message to Google Hangouts Chat (through webhook)
#
# The 'to' line given at netdata alarms defines a *role*, so that many
# people can be notified for each role.
@@ -176,6 +177,7 @@ sendsms=""
# kavenegar : "09155555555 09177777777|critical"
# pd : "<pd_service_key_1> <pd_service_key_2>|critical"
# irc : "<irc_channel_1> <irc_channel_2>|critical"
+# hangouts : "alarms disasters|critical"
#
# If a recipient is set to empty string, the default recipient of the given
# notification method (email, pushover, telegram, slack, alerta, etc) will be used.
@@ -228,6 +230,27 @@ DEFAULT_RECIPIENT_EMAIL="root"
#EMAIL_PLAINTEXT_ONLY="YES"
#------------------------------------------------------------------------------
+# hangouts (google hangouts chat) global notification options
+
+# enable/disable sending hangouts notifications
+SEND_HANGOUTS="YES"
+
+# On Hangouts, in the room you choose, create an incoming webhook,
+# copy the link and paste it below and also give it a room name.
+# Without it, netdata cannot send hangouts notifications to that room.
+# You will then use the same room name in your recipients list. For each URI, you need
+# HANGOUTS_WEBHOOK_URI[room_name]="WEBHOOK_URI"
+# e.g. to define systems and development rooms/recipients:
+# HANGOUTS_WEBHOOK_URI[systems]="URLforroom1"
+# HANGOUTS_WEBHOOK_URI[development]="URLforroom2"
+
+# if a DEFAULT_RECIPIENT_HANGOUTS is not configured,
+# notifications won't be send to hangouts rooms. For the example above,
+# a valid recipients list is the following
+# DEFAULT_RECIPIENT_HANGOUTS="systems development|critical"
+DEFAULT_RECIPIENT_HANGOUTS=""
+
+#------------------------------------------------------------------------------
# pushover (pushover.net) global notification options
# multiple recipients can be given like this:
@@ -375,10 +398,10 @@ SEND_SLACK="YES"
SLACK_WEBHOOK_URL=""
# if a role's recipients are not configured, a notification will be send to:
-# - A slack channel (syntax: '#channel' or 'channel')
+# - A slack channel (syntax: '#channel' or 'channel')
# - A slack user (syntax: '@user')
# - The channel or user defined in slack for the webhook (syntax: '#')
-# empty = do not send a notification for unconfigured roles
+# empty = do not send a notification for unconfigured roles
DEFAULT_RECIPIENT_SLACK=""
#------------------------------------------------------------------------------
@@ -640,7 +663,7 @@ SEND_SYSLOG="NO"
# configuration to change that needs to happen in the syslog daemon
# configuration, not here.
-# This controls which facility is used by defalt for logging. Defaults
+# This controls which facility is used by default for logging. Defaults
# to local6.
SYSLOG_FACILITY=''
@@ -808,6 +831,8 @@ custom_sender() {
role_recipients_email[sysadmin]="${DEFAULT_RECIPIENT_EMAIL}"
+role_recipients_hangouts[sysadmin]="${DEFAULT_RECIPIENT_HANGOUTS}"
+
role_recipients_pushover[sysadmin]="${DEFAULT_RECIPIENT_PUSHOVER}"
role_recipients_pushbullet[sysadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
@@ -853,6 +878,8 @@ role_recipients_rocketchat[sysadmin]="${DEFAULT_RECIPIENT_ROCKETCHAT}"
role_recipients_email[domainadmin]="${DEFAULT_RECIPIENT_EMAIL}"
+role_recipients_hangouts[domainadmin]="${DEFAULT_RECIPIENT_HANGOUTS}"
+
role_recipients_pushover[domainadmin]="${DEFAULT_RECIPIENT_PUSHOVER}"
role_recipients_pushbullet[domainadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
@@ -901,6 +928,8 @@ role_recipients_sms[domainadmin]="${DEFAULT_RECIPIENT_SMS}"
role_recipients_email[dba]="${DEFAULT_RECIPIENT_EMAIL}"
+role_recipients_hangouts[dba]="${DEFAULT_RECIPIENT_HANGOUTS}"
+
role_recipients_pushover[dba]="${DEFAULT_RECIPIENT_PUSHOVER}"
role_recipients_pushbullet[dba]="${DEFAULT_RECIPIENT_PUSHBULLET}"
@@ -949,6 +978,8 @@ role_recipients_sms[dba]="${DEFAULT_RECIPIENT_SMS}"
role_recipients_email[webmaster]="${DEFAULT_RECIPIENT_EMAIL}"
+role_recipients_hangouts[webmaster]="${DEFAULT_RECIPIENT_HANGOUTS}"
+
role_recipients_pushover[webmaster]="${DEFAULT_RECIPIENT_PUSHOVER}"
role_recipients_pushbullet[webmaster]="${DEFAULT_RECIPIENT_PUSHBULLET}"
@@ -997,6 +1028,8 @@ role_recipients_sms[webmaster]="${DEFAULT_RECIPIENT_SMS}"
role_recipients_email[proxyadmin]="${DEFAULT_RECIPIENT_EMAIL}"
+role_recipients_hangouts[proxyadmin]="${DEFAULT_RECIPIENT_HANGOUTS}"
+
role_recipients_pushover[proxyadmin]="${DEFAULT_RECIPIENT_PUSHOVER}"
role_recipients_pushbullet[proxyadmin]="${DEFAULT_RECIPIENT_PUSHBULLET}"
@@ -1046,6 +1079,8 @@ role_recipients_sms[proxyadmin]="${DEFAULT_RECIPIENT_SMS}"
role_recipients_email[sitemgr]="${DEFAULT_RECIPIENT_EMAIL}"
+role_recipients_hangouts[sitemgr]="${DEFAULT_RECIPIENT_HANGOUTS}"
+
role_recipients_pushover[sitemgr]="${DEFAULT_RECIPIENT_PUSHOVER}"
role_recipients_pushbullet[sitemgr]="${DEFAULT_RECIPIENT_PUSHBULLET}"