From 93c87c2cee998f9722637bef5beb61c3c66fadc8 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Fri, 13 Apr 2018 12:26:43 +0200
Subject: [PATCH] Update notification settings to incorporate new features

---
 templates/health_alarm_notify.conf | 311 ++++++++++++++++++++++++++---
 1 file changed, 287 insertions(+), 24 deletions(-)

diff --git a/templates/health_alarm_notify.conf b/templates/health_alarm_notify.conf
index b6a7baa..4cce272 100644
--- a/templates/health_alarm_notify.conf
+++ b/templates/health_alarm_notify.conf
@@ -7,11 +7,14 @@
 # - e-mails (using the sendmail command),
 # - push notifications to your mobile phone (pushover.net),
 # - messages to your slack team (slack.com),
+# - messages to your alerta server (alerta.io),
+# - messages to your flock team (flock.com),
 # - messages to your discord guild (discordapp.com),
 # - messages to your telegram chat / group chat (telegram.org)
 # - sms messages to your cell phone or any sms enabled device (twilio.com)
 # - sms messages to your cell phone or any sms enabled device (messagebird.com)
 # - notifications to users on pagerduty.com
+# - messages to your irc channel on your selected network
 #
 # The 'to' line given at netdata alarms defines a *role*, so that many
 # people can be notified for each role.
@@ -22,8 +25,8 @@
 #------------------------------------------------------------------------------
 # proxy configuration
 #
-# If you need to send curl based notifications (pushover, pushbullet, slack,
-# discord, telegram) via a proxy, set these to your proxy address:
+# If you need to send curl based notifications (pushover, pushbullet, slack, alerta,
+# flock, discord, telegram) via a proxy, set these to your proxy address:
 #export http_proxy="http://10.0.0.1:3128/"
 #export https_proxy="http://10.0.0.1:3128/"
 
@@ -53,6 +56,23 @@ sendmail=""
 # If not found, most notifications will be silently disabled.
 curl=""
 
+# The full path of the nc command.
+# If empty, the system $PATH will be searched for it.
+# If not found, irc notifications will be silently disabled.
+nc=""
+
+#------------------------------------------------------------------------------
+# extra options for external commands
+#
+# In some cases, you may need to change what options get passed to an
+# external command.  Such cases are covered here.
+
+# Extra options to pass to curl.  In most cases, you shouldn't need to add anything
+# to this.  If you're having issues with HTTPS connections, you might try adding
+# '--insecure' here, but be warned that it will make it much easier for
+# third-parties to block notification delivery, and may allow disclosure
+# of potentially sensitive information.
+#curl_options="--insecure"
 
 #------------------------------------------------------------------------------
 # NOTE ABOUT RECIPIENTS
@@ -63,10 +83,13 @@ curl=""
 #  - pushover user tokens
 #  - telegram chat ids
 #  - slack channels
+#  - alerta environment
+#  - flock rooms
 #  - discord channels
 #  - hipchat rooms
 #  - sms phone numbers
 #  - pagerduty.com (pd) services
+#  - irc channels
 #
 # You can append |critical to limit the notifications to be sent.
 #
@@ -77,43 +100,35 @@ curl=""
 #  pushover   : "2987343...9437837 8756278...2362736|critical"
 #  telegram   : "111827421 112746832|critical"
 #  slack      : "alarms disasters|critical"
+#  alerta     : "alarms disasters|critical"
+#  flock      : "alarms disasters|critical"
 #  discord    : "alarms disasters|critical"
 #  twilio     : "+15555555555 +17777777777|critical"
 #  messagebird: "+15555555555 +17777777777|critical"
+#  kavenegar  : "09155555555 09177777777|critical"
 #  pd         : "<pd_service_key_1> <pd_service_key_2>|critical"
+#  irc        : "<irc_channel_1> <irc_channel_2>|critical"
 #
 # If a recipient is set to empty string, the default recipient of the given
-# notification method (email, pushover, telegram, slack, etc) will be used.
+# notification method (email, pushover, telegram, slack, alerta, etc) will be used.
 # To disable a notification, use the recipient called: disabled
 # This works for all notification methods (including the default recipients).
 
-#------------------------------------------------------------------------------
-# alerta global notification options
-
-# enable/disable sending alerta notifications
-SEND_ALERTA="{{ netdata_alerta_enabled|default('NO') }}"
-
-# here set your alerta server API url
-# this is the API url you defined when installed Alerta server,
-# it is the same for all users. Do not include last slash.
-ALERTA_WEBHOOK_URL="{{ netdata_alerta_webhook|default('') }}"
-
-# Login with an administrative user to you Alerta server and create an API KEY
-# with write permissions.
-ALERTA_API_KEY="{{ netdata_alerta_apikey|default('') }}"
-
-# you can define environments in /etc/alertad.conf option ALLOWED_ENVIRONMENTS
-# standard environments are Production and Development
-# if a role's recipients are not configured, a notification will be send to
-# this Environment (empty = do not send a notification for unconfigured roles):
-DEFAULT_RECIPIENT_ALERTA="{{ netdata_alerta_environment|default('production') }}"
-
 #------------------------------------------------------------------------------
 # email global notification options
 
 # multiple recipients can be given like this:
 #              "admin1@example.com admin2@example.com ..."
 
+# the email address sending email notifications
+# the default is the system user netdata runs as (usually: netdata)
+# The following formats are supported:
+# EMAIL_SENDER="user@domain"
+# EMAIL_SENDER="User Name <user@domain>"
+# EMAIL_SENDER="'User Name' <user@domain>"
+# EMAIL_SENDER="\"User Name\" <user@domain>"
+EMAIL_SENDER=""
+
 # enable/disable sending emails
 SEND_EMAIL="{{ netdata_email_enabled|default('NO') }}"
 
@@ -121,6 +136,13 @@ SEND_EMAIL="{{ netdata_email_enabled|default('NO') }}"
 DEFAULT_RECIPIENT_EMAIL="root"
 # to receive only critical alarms, set it to "root|critical"
 
+# Optionally specify the encoding to list in the Content-Type header.
+# This doesn't change what encoding the e-mail is sent with, just what
+# the headers say it was encoded as.
+# This shouldn't need to be changed as it will almost always be
+# autodetected from the environment.
+#EMAIL_CHARSET="UTF-8"
+
 
 #------------------------------------------------------------------------------
 # pushover (pushover.net) global notification options
@@ -164,6 +186,9 @@ SEND_PUSHBULLET="{{ netdata_pushbullet_enabled|default('NO') }}"
 PUSHBULLET_ACCESS_TOKEN="{{ netdata_pushbullet_token|default('') }}"
 DEFAULT_RECIPIENT_PUSHBULLET="{{ netdata_pushbullet_recipient|default('') }}"
 
+# Device iden of the sending device. Optional.
+PUSHBULLET_SOURCE_DEVICE=""
+
 
 #------------------------------------------------------------------------------
 # Twilio (twilio.com) SMS options
@@ -208,6 +233,28 @@ MESSAGEBIRD_NUMBER="{{ netdata_messagebird_number|default('') }}"
 DEFAULT_RECIPIENT_MESSAGEBIRD="{{ netdata_messagebird_recipient|default('') }}"
 
 
+#------------------------------------------------------------------------------
+# Kavenegar (Kavenegar.com) SMS options
+
+# multiple recipients can be given like this:
+#                  "09155555555 09177777777"
+
+# enable/disable sending kavenegar SMS
+SEND_KAVENEGAR="YES"
+
+# to get an access key, after selecting and purchasing your desired service
+# at http://kavenegar.com/pricing.html
+# login to your account, go to your dashboard and my account are
+# https://panel.kavenegar.com/Client/setting/account from API Key
+# copy your api key. You can generate new API Key too.
+# You can find and select kevenegar sender number from this place.
+
+# Without an API key, netdata cannot send KAVENEGAR text messages.
+KAVENEGAR_API_KEY=""
+KAVENEGAR_SENDER=""
+DEFAULT_RECIPIENT_KAVENEGAR=""
+
+
 #------------------------------------------------------------------------------
 # telegram (telegram.org) global notification options
 
@@ -250,6 +297,47 @@ SLACK_WEBHOOK_URL="{{ netdata_slack_webhook|default('') }}"
 DEFAULT_RECIPIENT_SLACK="{{ netdata_slack_channel|default('') }}"
 
 
+#------------------------------------------------------------------------------
+# alerta (alerta.io) global notification options
+
+# multiple recipients (Environments) can be given like this:
+#                  "Production Development ..."
+
+# enable/disable sending alerta notifications
+SEND_ALERTA="{{ netdata_alerta_enabled|default('NO') }}"
+
+# here set your alerta server API url
+# this is the API url you defined when installed Alerta server,
+# it is the same for all users. Do not include last slash.
+# ALERTA_WEBHOOK_URL="https://<server>/alerta/api"
+ALERTA_WEBHOOK_URL="{{ netdata_alerta_webhook|default('') }}"
+
+# Login with an administrative user to you Alerta server and create an API KEY
+# with write permissions.
+ALERTA_API_KEY="{{ netdata_alerta_apikey|default('') }}"
+
+# you can define environments in /etc/alertad.conf option ALLOWED_ENVIRONMENTS
+# standard environments are Production and Development
+# if a role's recipients are not configured, a notification will be send to
+# this Environment (empty = do not send a notification for unconfigured roles):
+DEFAULT_RECIPIENT_ALERTA="{{ netdata_alerta_environment|default('production') }}"
+
+
+#------------------------------------------------------------------------------
+# flock (flock.com) global notification options
+
+# enable/disable sending flock notifications
+SEND_FLOCK="YES"
+
+# Login to flock.com and create an incoming webhook. You need only one for all
+# your netdata servers (or you can have one for each of your netdata).
+# Without it, netdata cannot send flock notifications.
+FLOCK_WEBHOOK_URL=""
+
+# if a role recipient is not configured, no notification will be sent
+DEFAULT_RECIPIENT_FLOCK=""
+
+
 #------------------------------------------------------------------------------
 # discord (discordapp.com) global notification options
 
@@ -278,6 +366,9 @@ DEFAULT_RECIPIENT_DISCORD="{{ netdata_discord_recipient|default('') }}"
 # enable/disable sending hipchat notifications
 SEND_HIPCHAT="{{ netdata_hipchat_enabled|default('NO') }}"
 
+# define hipchat server
+HIPCHAT_SERVER="api.hipchat.com"
+
 # api.hipchat.com authorization token
 # Without this, netdata cannot send hipchat notifications.
 HIPCHAT_AUTH_TOKEN="{{ netdata_hipchat_token|default('') }}"
@@ -320,6 +411,96 @@ SEND_PD="{{ netdata_pagerduty_enabled|default('NO') }}"
 DEFAULT_RECIPIENT_PD="{{ netdata_pagerduty_recipient|default('') }}"
 
 
+#------------------------------------------------------------------------------
+# irc notification options
+#
+# irc notifications require only the nc utility to be installed.
+
+# multiple recipients can be given like this:
+#              "<irc_channel_1> <irc_channel_2> ..."
+
+# enable/disable sending irc notifications
+SEND_IRC="YES"
+
+# if a role's recipients are not configured, a notification will not be sent.
+# (empty = do not send a notification for unconfigured roles):
+DEFAULT_RECIPIENT_IRC=""
+
+# The irc network to which the recipients belong. It must be the full network.
+# e.g. "irc.freenode.net"
+IRC_NETWORK=""
+
+# The irc nickname which is required to send the notification. It must not be
+# an already registered name as the connection's MODE is defined as a 'guest'.
+IRC_NICKNAME=""
+
+# The irc realname which is required in order to make the connection and is an
+# extra identifier.
+IRC_REALNAME=""
+
+
+#------------------------------------------------------------------------------
+# custom notifications
+#
+
+# enable/disable sending custom notifications
+SEND_CUSTOM="NO"
+
+# if a role's recipients are not configured, use the following.
+# (empty = do not send a notification for unconfigured roles)
+DEFAULT_RECIPIENT_CUSTOM=""
+
+# The custom_sender() is a custom function to do whatever you need to do
+custom_sender() {
+    # variables you can use:
+    # ${host}               the host generated this event
+    # ${url_host}           same as ${host} but URL encoded
+    # ${unique_id}          the unique id of this event
+    # ${alarm_id}           the unique id of the alarm that generated this event
+    # ${event_id}           the incremental id of the event, for this alarm id
+    # ${when}               the timestamp this event occurred
+    # ${name}               the name of the alarm, as given in netdata health.d entries
+    # ${url_name}           same as ${name} but URL encoded
+    # ${chart}              the name of the chart (type.id)
+    # ${url_chart}          same as ${chart} but URL encoded
+    # ${family}             the family of the chart
+    # ${url_family}         same as ${family} but URL encoded
+    # ${status}             the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
+    # ${old_status}         the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
+    # ${value}              the current value of the alarm
+    # ${old_value}          the previous value of the alarm
+    # ${src}                the line number and file the alarm has been configured
+    # ${duration}           the duration in seconds of the previous alarm state
+    # ${duration_txt}       same as ${duration} for humans
+    # ${non_clear_duration} the total duration in seconds this is/was non-clear
+    # ${non_clear_duration_txt} same as ${non_clear_duration} for humans
+    # ${units}              the units of the value
+    # ${info}               a short description of the alarm
+    # ${value_string}       friendly value (with units)
+    # ${old_value_string}   friendly old value (with units)
+    # ${image}              the URL of an image to represent the status of the alarm
+    # ${color}              a color in #AABBCC format for the alarm
+    # ${goto_url}           the URL the user can click to see the netdata dashboard
+
+    # these are more human friendly:
+    # ${alarm}              like "name = value units"
+    # ${status_message}     like "needs attention", "recovered", "is critical"
+    # ${severity}           like "Escalated to CRITICAL", "Recovered from WARNING"
+    # ${raised_for}         like "(alarm was raised for 10 minutes)"
+
+    # example human readable SMS
+    local msg="${host} ${status_message}: ${alarm} ${raised_for}"
+
+    # limit it to 160 characters and encode it for use in a URL
+    urlencode "${msg:0:160}" >/dev/null; msg="${REPLY}"
+
+    # a space separated list of the recipients to send alarms to
+    to="${1}"
+
+    info "not sending custom notification to ${to}, for ${status} of '${host}.${chart}.${name}' - custom_sender() is not configured."
+}
+
+
 ###############################################################################
 # RECIPIENTS PER ROLE
 
@@ -337,6 +518,10 @@ role_recipients_telegram[sysadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
 
 role_recipients_slack[sysadmin]="${DEFAULT_RECIPIENT_SLACK}"
 
+role_recipients_alerta[sysadmin]="${DEFAULT_RECIPIENT_ALERTA}"
+
+role_recipients_flock[sysadmin]="${DEFAULT_RECIPIENT_FLOCK}"
+
 role_recipients_discord[sysadmin]="${DEFAULT_RECIPIENT_DISCORD}"
 
 role_recipients_hipchat[sysadmin]="${DEFAULT_RECIPIENT_HIPCHAT}"
@@ -345,8 +530,14 @@ role_recipients_twilio[sysadmin]="${DEFAULT_RECIPIENT_TWILIO}"
 
 role_recipients_messagebird[sysadmin]="${DEFAULT_RECIPIENT_MESSAGEBIRD}"
 
+role_recipients_kavenegar[sysadmin]="${DEFAULT_RECIPIENT_KAVENEGAR}"
+
 role_recipients_pd[sysadmin]="${DEFAULT_RECIPIENT_PD}"
 
+role_recipients_irc[sysadmin]="${DEFAULT_RECIPIENT_IRC}"
+
+role_recipients_custom[sysadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
+
 # -----------------------------------------------------------------------------
 # DNS related alarms
 
@@ -360,6 +551,10 @@ role_recipients_telegram[domainadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
 
 role_recipients_slack[domainadmin]="${DEFAULT_RECIPIENT_SLACK}"
 
+role_recipients_alerta[domainadmin]="${DEFAULT_RECIPIENT_ALERTA}"
+
+role_recipients_flock[domainadmin]="${DEFAULT_RECIPIENT_FLOCK}"
+
 role_recipients_discord[domainadmin]="${DEFAULT_RECIPIENT_DISCORD}"
 
 role_recipients_hipchat[domainadmin]="${DEFAULT_RECIPIENT_HIPCHAT}"
@@ -368,8 +563,14 @@ role_recipients_twilio[domainadmin]="${DEFAULT_RECIPIENT_TWILIO}"
 
 role_recipients_messagebird[domainadmin]="${DEFAULT_RECIPIENT_MESSAGEBIRD}"
 
+role_recipients_kavenegar[domainadmin]="${DEFAULT_RECIPIENT_KAVENEGAR}"
+
 role_recipients_pd[domainadmin]="${DEFAULT_RECIPIENT_PD}"
 
+role_recipients_irc[domainadmin]="${DEFAULT_RECIPIENT_IRC}"
+
+role_recipients_custom[domainadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
+
 # -----------------------------------------------------------------------------
 # database servers alarms
 # mysql, redis, memcached, postgres, etc
@@ -384,6 +585,10 @@ role_recipients_telegram[dba]="${DEFAULT_RECIPIENT_TELEGRAM}"
 
 role_recipients_slack[dba]="${DEFAULT_RECIPIENT_SLACK}"
 
+role_recipients_alerta[dba]="${DEFAULT_RECIPIENT_ALERTA}"
+
+role_recipients_flock[dba]="${DEFAULT_RECIPIENT_FLOCK}"
+
 role_recipients_discord[dba]="${DEFAULT_RECIPIENT_DISCORD}"
 
 role_recipients_hipchat[dba]="${DEFAULT_RECIPIENT_HIPCHAT}"
@@ -392,8 +597,14 @@ role_recipients_twilio[dba]="${DEFAULT_RECIPIENT_TWILIO}"
 
 role_recipients_messagebird[dba]="${DEFAULT_RECIPIENT_MESSAGEBIRD}"
 
+role_recipients_kavenegar[dba]="${DEFAULT_RECIPIENT_KAVENEGAR}"
+
 role_recipients_pd[dba]="${DEFAULT_RECIPIENT_PD}"
 
+role_recipients_irc[dba]="${DEFAULT_RECIPIENT_IRC}"
+
+role_recipients_custom[dba]="${DEFAULT_RECIPIENT_CUSTOM}"
+
 # -----------------------------------------------------------------------------
 # web servers alarms
 # apache, nginx, lighttpd, etc
@@ -408,6 +619,10 @@ role_recipients_telegram[webmaster]="${DEFAULT_RECIPIENT_TELEGRAM}"
 
 role_recipients_slack[webmaster]="${DEFAULT_RECIPIENT_SLACK}"
 
+role_recipients_alerta[webmaster]="${DEFAULT_RECIPIENT_ALERTA}"
+
+role_recipients_flock[webmaster]="${DEFAULT_RECIPIENT_FLOCK}"
+
 role_recipients_discord[webmaster]="${DEFAULT_RECIPIENT_DISCORD}"
 
 role_recipients_hipchat[webmaster]="${DEFAULT_RECIPIENT_HIPCHAT}"
@@ -416,8 +631,14 @@ role_recipients_twilio[webmaster]="${DEFAULT_RECIPIENT_TWILIO}"
 
 role_recipients_messagebird[webmaster]="${DEFAULT_RECIPIENT_MESSAGEBIRD}"
 
+role_recipients_kavenegar[webmaster]="${DEFAULT_RECIPIENT_KAVENEGAR}"
+
 role_recipients_pd[webmaster]="${DEFAULT_RECIPIENT_PD}"
 
+role_recipients_irc[webmaster]="${DEFAULT_RECIPIENT_IRC}"
+
+role_recipients_custom[webmaster]="${DEFAULT_RECIPIENT_CUSTOM}"
+
 # -----------------------------------------------------------------------------
 # proxy servers alarms
 # squid, etc
@@ -432,6 +653,10 @@ role_recipients_telegram[proxyadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
 
 role_recipients_slack[proxyadmin]="${DEFAULT_RECIPIENT_SLACK}"
 
+role_recipients_alerta[proxyadmin]="${DEFAULT_RECIPIENT_ALERTA}"
+
+role_recipients_flock[proxyadmin]="${DEFAULT_RECIPIENT_FLOCK}"
+
 role_recipients_discord[proxyadmin]="${DEFAULT_RECIPIENT_DISCORD}"
 
 role_recipients_hipchat[proxyadmin]="${DEFAULT_RECIPIENT_HIPCHAT}"
@@ -440,4 +665,42 @@ role_recipients_twilio[proxyadmin]="${DEFAULT_RECIPIENT_TWILIO}"
 
 role_recipients_messagebird[proxyadmin]="${DEFAULT_RECIPIENT_MESSAGEBIRD}"
 
+role_recipients_kavenegar[proxyadmin]="${DEFAULT_RECIPIENT_KAVENEGAR}"
+
 role_recipients_pd[proxyadmin]="${DEFAULT_RECIPIENT_PD}"
+
+role_recipients_irc[proxyadmin]="${DEFAULT_RECIPIENT_IRC}"
+
+role_recipients_custom[proxyadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
+
+# -----------------------------------------------------------------------------
+# peripheral devices
+# UPS, photovoltaics, etc
+
+role_recipients_email[sitemgr]="${DEFAULT_RECIPIENT_EMAIL}"
+
+role_recipients_pushover[sitemgr]="${DEFAULT_RECIPIENT_PUSHOVER}"
+
+role_recipients_pushbullet[sitemgr]="${DEFAULT_RECIPIENT_PUSHBULLET}"
+
+role_recipients_telegram[sitemgr]="${DEFAULT_RECIPIENT_TELEGRAM}"
+
+role_recipients_slack[sitemgr]="${DEFAULT_RECIPIENT_SLACK}"
+
+role_recipients_alerta[sitemgr]="${DEFAULT_RECIPIENT_ALERTA}"
+
+role_recipients_flock[sitemgr]="${DEFAULT_RECIPIENT_FLOCK}"
+
+role_recipients_discord[sitemgr]="${DEFAULT_RECIPIENT_DISCORD}"
+
+role_recipients_hipchat[sitemgr]="${DEFAULT_RECIPIENT_HIPCHAT}"
+
+role_recipients_twilio[sitemgr]="${DEFAULT_RECIPIENT_TWILIO}"
+
+role_recipients_messagebird[sitemgr]="${DEFAULT_RECIPIENT_MESSAGEBIRD}"
+
+role_recipients_kavenegar[sitemgr]="${DEFAULT_RECIPIENT_KAVENEGAR}"
+
+role_recipients_pd[sitemgr]="${DEFAULT_RECIPIENT_PD}"
+
+role_recipients_custom[sitemgr]="${DEFAULT_RECIPIENT_CUSTOM}"
-- 
GitLab