|
@@ -769,6 +769,9 @@ fi
|
|
|
# check custom
|
|
|
[ -z "${DEFAULT_RECIPIENT_CUSTOM}" ] && SEND_CUSTOM="NO"
|
|
|
|
|
|
+# check ilert
|
|
|
+[ -z "${ILERT_ALERT_SOURCE_URL}" ] && SEND_ILERT="NO"
|
|
|
+
|
|
|
# -----------------------------------------------------------------------------
|
|
|
# check the availability of targets
|
|
|
|
|
@@ -798,7 +801,8 @@ check_supported_targets() {
|
|
|
[ "${SEND_DYNATRACE}" = "YES" ] ||
|
|
|
[ "${SEND_OPSGENIE}" = "YES" ] ||
|
|
|
[ "${SEND_GOTIFY}" = "YES" ] ||
|
|
|
- [ "${SEND_NTFY}" = "YES" ]; then
|
|
|
+ [ "${SEND_NTFY}" = "YES" ] ||
|
|
|
+ [ "${SEND_ILERT}" = "YES" ]; then
|
|
|
# if we need curl, check for the curl command
|
|
|
if [ -z "${curl}" ]; then
|
|
|
curl="$(command -v curl 2>/dev/null)"
|
|
@@ -828,6 +832,7 @@ check_supported_targets() {
|
|
|
SEND_OPSGENIE="NO"
|
|
|
SEND_GOTIFY="NO"
|
|
|
SEND_NTFY="NO"
|
|
|
+ SEND_ILERT="NO"
|
|
|
fi
|
|
|
fi
|
|
|
|
|
@@ -983,7 +988,8 @@ for method in "${SEND_EMAIL}" \
|
|
|
"${SEND_DYNATRACE}" \
|
|
|
"${SEND_OPSGENIE}" \
|
|
|
"${SEND_GOTIFY}" \
|
|
|
- "${SEND_NTFY}" ; do
|
|
|
+ "${SEND_NTFY}" \
|
|
|
+ "${SEND_ILERT}" ; do
|
|
|
|
|
|
if [ "${method}" == "YES" ]; then
|
|
|
proceed=1
|
|
@@ -2431,6 +2437,50 @@ send_ntfy() {
|
|
|
return 1
|
|
|
}
|
|
|
|
|
|
+# -----------------------------------------------------------------------------
|
|
|
+# ilert sender
|
|
|
+
|
|
|
+send_ilert() {
|
|
|
+ local payload httpcode
|
|
|
+ [ "${SEND_ILERT}" != "YES" ] && return 1
|
|
|
+
|
|
|
+ if [ -z "${ILERT_ALERT_SOURCE_URL}" ] ; then
|
|
|
+ info "Can't send ilert notification, because ILERT_ALERT_SOURCE_URL is not defined"
|
|
|
+ return 1
|
|
|
+ fi
|
|
|
+
|
|
|
+ payload=$(cat <<EOF
|
|
|
+ {
|
|
|
+ "alert" : "${name}",
|
|
|
+ "alert_url" : "${goto_url}",
|
|
|
+ "alarm_id" : ${alarm_id},
|
|
|
+ "chart" : "${chart}",
|
|
|
+ "date" : "${when}",
|
|
|
+ "duration" : "${duration_txt}",
|
|
|
+ "host" : "${host}",
|
|
|
+ "info" : "${info}",
|
|
|
+ "message" : "${status_message}",
|
|
|
+ "severity": ${status},
|
|
|
+ "total_critical" : "${total_critical}",
|
|
|
+ "total_warnings" : "${total_warnings}",
|
|
|
+ "value" : "${value_string}",
|
|
|
+ "image_url": "${image}",
|
|
|
+ "src" : "${src}"
|
|
|
+ }
|
|
|
+EOF
|
|
|
+)
|
|
|
+
|
|
|
+ httpcode=$(docurl -X POST -H "Content-Type: application/json" -d "${payload}" "${ILERT_ALERT_SOURCE_URL}")
|
|
|
+ if [ "${httpcode}" = "200" ] || [ "${httpcode}" = "202" ]; then
|
|
|
+ info "sent ilert event for ${notification_description}"
|
|
|
+ else
|
|
|
+ error "failed to send ilert event for ${notification_description}, with HTTP response status code ${httpcode}."
|
|
|
+ return 1
|
|
|
+ fi
|
|
|
+
|
|
|
+ return 0
|
|
|
+}
|
|
|
+
|
|
|
# -----------------------------------------------------------------------------
|
|
|
# prepare the content of the notification
|
|
|
|
|
@@ -3603,6 +3653,11 @@ SENT_GOTIFY=$?
|
|
|
send_ntfy "${DEFAULT_RECIPIENT_NTFY}"
|
|
|
SENT_NTFY=$?
|
|
|
|
|
|
+# -----------------------------------------------------------------------------
|
|
|
+# send messages to ilert
|
|
|
+send_ilert
|
|
|
+SENT_ILERT=$?
|
|
|
+
|
|
|
# -----------------------------------------------------------------------------
|
|
|
# let netdata know
|
|
|
for state in "${SENT_EMAIL}" \
|
|
@@ -3632,7 +3687,8 @@ for state in "${SENT_EMAIL}" \
|
|
|
"${SENT_DYNATRACE}" \
|
|
|
"${SENT_OPSGENIE}" \
|
|
|
"${SENT_GOTIFY}" \
|
|
|
- "${SENT_NTFY}"; do
|
|
|
+ "${SENT_NTFY}" \
|
|
|
+ "${SENT_ILERT}"; do
|
|
|
if [ "${state}" -eq 0 ]; then
|
|
|
# we sent something
|
|
|
exit 0
|