###############################################################################
# proxy configuration
#
-# if you need to send curl based notifications (pushover, slack, telegram)
+# If you need to send curl based notifications (pushover, slack, 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/"
###############################################################################
-# external commands needed
+# notifications images
+#
+# Images in notifications need to be downloaded from an Internet facing site.
+# To allow notification providers fetch the icons/images, by default we set
+# the URL of the global public netdata registry.
+# If you have an Internet facing netdata (or you have copied the images/ folder
+# of netdata to your web server), set its URL here, to fetch the notification
+# images from it.
+#images_base_url="http://my.public.netdata.server:19999"
+
+
+###############################################################################
+# external commands
# The full path to the sendmail command.
# If empty, the system $PATH will be searched for it.
role_recipients_telegram[proxyadmin]="${DEFAULT_RECIPIENT_TELEGRAM}"
role_recipients_slack[proxyadmin]="${DEFAULT_RECIPIENT_SLACK}"
+
# -----------------------------------------------------------------------------
# parse command line parameters
-recipient="${1}" # the recepient of the email
-host="${2}" # the host this event refers to
+roles="${1}" # the roles that should be notified for this event
+host="${2}" # the host generated this event
unique_id="${3}" # the unique id of this event
alarm_id="${4}" # the unique id of the alarm that generated this event
-event_id="${5}" # the incremental id of the event, for this alarm
-when="${6}" # the timestamp this event occured
+event_id="${5}" # the incremental id of the event, for this alarm id
+when="${6}" # the timestamp this event occurred
name="${7}" # the name of the alarm, as given in netdata health.d entries
chart="${8}" # the name of the chart (type.id)
family="${9}" # the family of the chart
status="${10}" # the current status : REMOVED, UNITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
old_status="${11}" # the previous status: REMOVED, UNITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
-value="${12}" # the current value
-old_value="${13}" # the previous value
+value="${12}" # the current value of the alarm
+old_value="${13}" # the previous value of the alarm
src="${14}" # the line number and file the alarm has been configured
-duration="${15}" # the duration in seconds the previous state took
-non_clear_duration="${16}" # the total duration in seconds this is non-clear
+duration="${15}" # the duration in seconds of the previous alarm state
+non_clear_duration="${16}" # the total duration in seconds this is/was non-clear
units="${17}" # the units of the value
info="${18}" # a short description of the alarm
# -----------------------------------------------------------------------------
# load configuration
-# this is defined here so that private registries
-# can setup their own
-# images_base_url="${NETDATA_REGISTRY_URL}"
+# By default fetch images from the global public registry.
+# This is required by default, since all notification methods need to download
+# images via the Internet, and private registries might not be reachable.
+# This can be overwritten at the configuration file.
images_base_url="https://registry.my-netdata.io"
# needed commands
fi
# -----------------------------------------------------------------------------
-# filter recipients based on the criticality of each
+# filter a recipient based on alarm event severity
filter_recipient_by_criticality() {
local method="${1}" x="${2}" r s
shift
- r="${x/|*/}"
- s="${x/*|/}"
+ r="${x/|*/}" # the recipient
+ s="${x/*|/}" # the severity required for notifying this recipient
# no severity filtering for this person
[ "${r}" = "${s}" ] && return 0
}
# -----------------------------------------------------------------------------
-# find the recipient's addresses per method
+# find the recipients' addresses per method
declare -A arr_slack=()
declare -A arr_pushover=()
declare -A arr_telegram=()
declare -A arr_email=()
-# netdata may call us with multiple recipients
-# so, here we find the unique ones
-for x in ${recipient//,/ }
+# netdata may call us with multiple roles, and roles may have multiple but
+# overlapping recipients - so, here we find the unique recipients.
+for x in ${roles//,/ }
do
- # the recipient 'silent' means, don't send a notification for this event
- [ "${x}" = "silent" ] && continue
+ # the roles 'silent' and 'disabled' mean:
+ # don't send a notification for this role
+ [ "${x}" = "silent" -o "${x}" = "disabled" ] && continue
# email
- a="${role_recipients_email[${recipient}]}"
+ a="${role_recipients_email[${x}]}"
[ -z "${a}" ] && a="${DEFAULT_RECIPIENT_EMAIL}"
for r in ${a//,/ }
do
done
# pushover
- a="${role_recipients_pushover[${recipient}]}"
+ a="${role_recipients_pushover[${x}]}"
[ -z "${a}" ] && a="${DEFAULT_RECIPIENT_PUSHOVER}"
for r in ${a//,/ }
do
done
# telegram
- a="${role_recipients_telegram[${recipient}]}"
+ a="${role_recipients_telegram[${x}]}"
[ -z "${a}" ] && a="${DEFAULT_RECIPIENT_TELEGRAM}"
for r in ${a//,/ }
do
done
# slack
- a="${role_recipients_slack[${recipient}]}"
+ a="${role_recipients_slack[${x}]}"
[ -z "${a}" ] && a="${DEFAULT_RECIPIENT_SLACK}"
for r in ${a//,/ }
do
# -----------------------------------------------------------------------------
# let netdata know
-# we did send somehting
+# we did send something
[ ${SENT_EMAIL} -eq 0 -o ${SENT_PUSHOVER} -eq 0 -o ${SENT_TELEGRAM} -eq 0 -o ${SENT_SLACK} -eq 0 ] && exit 0
# we did not send anything