summaryrefslogtreecommitdiffstats
path: root/plugins.d
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2017-08-16 14:54:02 +0300
committerGitHub <noreply@github.com>2017-08-16 14:54:02 +0300
commit1e93e5b3624e13394bd799d4a92055fa3f58ad91 (patch)
tree5c8958c789968e8e61f9d2250dccd1759c3a5982 /plugins.d
parentf0e29046889438bfb084f560c9cf32577935d640 (diff)
parent8b8ba4849d27615e2f7fc4b3c5a8ff44e8958a30 (diff)
Merge pull request #2588 from Ferroin/patch-1
Reduce notification e-mail spam score.
Diffstat (limited to 'plugins.d')
-rwxr-xr-xplugins.d/alarm-notify.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins.d/alarm-notify.sh b/plugins.d/alarm-notify.sh
index af15494017..ddfae68ddf 100755
--- a/plugins.d/alarm-notify.sh
+++ b/plugins.d/alarm-notify.sh
@@ -290,6 +290,7 @@ declare -A role_recipients_custom=()
# email configs
EMAIL_SENDER=""
DEFAULT_RECIPIENT_EMAIL="root"
+EMAIL_CHARSET=$(locale charmap 2>/dev/null)
declare -A role_recipients_email=()
# load the user configuration
@@ -301,6 +302,14 @@ else
error "Cannot find file ${NETDATA_CONFIG_DIR}/health_alarm_notify.conf. Using internal defaults."
fi
+# If we didn't autodetect the character set for e-mail and it wasn't
+# set by the user, we need to set it to a reasonable default. UTF-8
+# should be correct for almost all modern UNIX systems.
+if [ -z ${EMAIL_CHARSET} ]
+ then
+ EMAIL_CHARSET="UTF-8"
+fi
+
# -----------------------------------------------------------------------------
# filter a recipient based on alarm event severity
@@ -1401,7 +1410,9 @@ Content-Type: multipart/alternative; boundary="multipart-boundary"
This is a MIME-encoded multipart message
--multipart-boundary
-Content-Type: text/plain
+Content-Type: text/plain; encoding=${EMAIL_CHARSET}
+Content-Disposition: inline
+Content-Transfer-Encoding: 8bit
${host} ${status_message}
@@ -1417,7 +1428,9 @@ Date : ${date}
Notification generated on ${this_host}
--multipart-boundary
-Content-Type: text/html
+Content-Type: text/html; encoding=${EMAIL_CHARSET}
+Content-Disposition: inline
+Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0; padding: 0;">