From a9c43678db7671a1c575f197299695de446dcee1 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 07:24:32 +0200 Subject: made smtp auth optional --- start-munin.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/start-munin.sh b/start-munin.sh index c3aa70b..954a112 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -3,15 +3,23 @@ NODES=${NODES:-} SNMP_NODES=${SNMP_NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} +MAIL_CONF_PATH='/var/lib/munin/.mailrc' -if [ -n "${SMTP_USERNAME}" -a -n "${SMTP_PASSWORD}" -a -n "${SMTP_HOST}" -a -n "${SMTP_PORT}" ] ; then - cat > /var/lib/munin/.mailrc <> "${MAIL_CONF_PATH}" <> "${MAIL_CONF_PATH}" < Date: Wed, 1 Jun 2016 08:14:11 +0200 Subject: made tls optional --- start-munin.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/start-munin.sh b/start-munin.sh index 954a112..bed2e80 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -4,13 +4,19 @@ SNMP_NODES=${SNMP_NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' +SMTP_USE_TLS=false truncate -s 0 "${MAIL_CONF_PATH}" -if [ -n "${SMTP_HOST}" -a -n "${SMTP_PORT}" ] ; then +if [ "${SMTP_USE_TLS}" = true ] ; then cat >> "${MAIL_CONF_PATH}" <> "${MAIL_CONF_PATH}" < Date: Wed, 1 Jun 2016 08:27:17 +0200 Subject: added smtp_always_send parameter; documented smtp_always_send and smtp_use_tls parameters --- README.md | 4 ++++ start-munin.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 90bd619..c01c366 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Email credentials used to send emails (like alerts) * `SMTP_PORT` * `SMTP_USERNAME` * `SMTP_PASSWORD` +* `SMTP_USE_TLS` +* `SMTP_ALWAYS_SEND` ### Alert target @@ -63,6 +65,8 @@ docker run -d \ -e SMTP_PORT=587 \ -e SMTP_USERNAME=smtp-username \ -e SMTP_PASSWORD=smtp-password \ + -e SMTP_USE_TLS=false \ + -e SMTP_ALWAYS_SEND=true \ -e ALERT_RECIPIENT=monitoring@example.com \ -e ALERT_SENDER=alerts@example.com \ -e NODES="server1:10.0.0.1 server2:10.0.0.2" \ diff --git a/start-munin.sh b/start-munin.sh index bed2e80..e994128 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -5,6 +5,7 @@ MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' SMTP_USE_TLS=false +SMTP_ALWAYS_SEND=true truncate -s 0 "${MAIL_CONF_PATH}" @@ -33,6 +34,9 @@ grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" echo 'contact.mail.command mail -r '${ALERT_SENDER}' -s "[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}"' ${ALERT_RECIPIENT} >> /etc/munin/munin.conf + if [ "${SMTP_ALWAYS_SEND}" = true ] ; then + echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf + fi fi [ -e /etc/munin/htpasswd.users ] || htpasswd -b -c /etc/munin/htpasswd.users "$MUNIN_USER" "$MUNIN_PASSWORD" -- cgit v1.2.1 From a1fe06d2383628d71e265acc9be544159a413cc1 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 08:58:24 +0200 Subject: fixed smtp_use_tls and smtp_alway_send parameter value overrides --- start-munin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start-munin.sh b/start-munin.sh index e994128..a7209f7 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -4,8 +4,8 @@ SNMP_NODES=${SNMP_NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' -SMTP_USE_TLS=false -SMTP_ALWAYS_SEND=true +SMTP_USE_TLS=${SMTP_USE_TLS:-false} +SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} truncate -s 0 "${MAIL_CONF_PATH}" -- cgit v1.2.1 From c88f6adeb932998772b12545b7ace69578275150 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:03:54 +0200 Subject: exported smtp_message as configuration parameter --- start-munin.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/start-munin.sh b/start-munin.sh index a7209f7..58b3d0a 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -6,6 +6,8 @@ MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} MAIL_CONF_PATH='/var/lib/munin/.mailrc' SMTP_USE_TLS=${SMTP_USE_TLS:-false} SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} +SMTP_MESSAGE_DEFAULT='[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}' +SMTP_MESSAGE="${SMTP_MESSAGE:-$SMTP_MESSAGE_DEFAULT}" truncate -s 0 "${MAIL_CONF_PATH}" @@ -33,7 +35,7 @@ fi grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" - echo 'contact.mail.command mail -r '${ALERT_SENDER}' -s "[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}"' ${ALERT_RECIPIENT} >> /etc/munin/munin.conf + echo "contact.mail.command mail -r ${ALERT_SENDER} -s ${SMTP_MESSAGE} ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf if [ "${SMTP_ALWAYS_SEND}" = true ] ; then echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf fi -- cgit v1.2.1 From 72d8ed73758e676f3c7930f69b856ef7d9b3d10c Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:06:07 +0200 Subject: documented smtp_message parameter --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c01c366..5e58f03 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ docker run -d \ -e SMTP_PASSWORD=smtp-password \ -e SMTP_USE_TLS=false \ -e SMTP_ALWAYS_SEND=true \ + -e SMTP_MESSAGE='[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}' \ -e ALERT_RECIPIENT=monitoring@example.com \ -e ALERT_SENDER=alerts@example.com \ -e NODES="server1:10.0.0.1 server2:10.0.0.2" \ -- cgit v1.2.1 From b4cde28f0c82217fd24acce7283a8e1f4cbafd2b Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:30:53 +0200 Subject: added smtp_message to the listed envrionment variables --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5e58f03..783c2d5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Email credentials used to send emails (like alerts) * `SMTP_PASSWORD` * `SMTP_USE_TLS` * `SMTP_ALWAYS_SEND` +* `SMTP_MESSAGE` ### Alert target -- cgit v1.2.1 From 55e3dc2f06721d697935bdc0a820352675b8b185 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:37:03 +0200 Subject: fixed quoting of smtp_message environment variable --- start-munin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-munin.sh b/start-munin.sh index 58b3d0a..235a7e4 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -35,7 +35,7 @@ fi grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" - echo "contact.mail.command mail -r ${ALERT_SENDER} -s ${SMTP_MESSAGE} ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf +echo "contact.mail.command mail -r ${ALERT_SENDER} -s \'${SMTP_MESSAGE}\' ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf if [ "${SMTP_ALWAYS_SEND}" = true ] ; then echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf fi -- cgit v1.2.1 From 5ebec8d1b9fe51d074b351e1cfe0a307d086bc48 Mon Sep 17 00:00:00 2001 From: Michael Lewkowski Date: Wed, 1 Jun 2016 09:53:36 +0200 Subject: removed unnecessary escaping of the smtp message env. var --- start-munin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-munin.sh b/start-munin.sh index 235a7e4..8a050de 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -35,7 +35,7 @@ fi grep -q 'contact.mail' /etc/munin/munin.conf; rc=$? if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then echo "Setup alert email from ${ALERT_SENDER} to ${ALERT_RECIPIENT}" -echo "contact.mail.command mail -r ${ALERT_SENDER} -s \'${SMTP_MESSAGE}\' ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf + echo "contact.mail.command mail -r ${ALERT_SENDER} -s '${SMTP_MESSAGE}' ${ALERT_RECIPIENT}" >> /etc/munin/munin.conf if [ "${SMTP_ALWAYS_SEND}" = true ] ; then echo 'contact.mail.always_send warning critical' >> /etc/munin/munin.conf fi -- cgit v1.2.1