[Update] Remove obsolete parameters
[Compose] New watchdog image [Watchdog] Allow multiple rcpts separated by commamaster
parent
70a914a98c
commit
c9cf3476a0
|
@ -42,24 +42,29 @@ log_msg() {
|
||||||
|
|
||||||
function mail_error() {
|
function mail_error() {
|
||||||
[[ -z ${1} ]] && return 1
|
[[ -z ${1} ]] && return 1
|
||||||
[[ -z ${2} ]] && return 2
|
[[ -z ${2} ]] && BODY="Service was restarted on $(date), please check your mailcow installation." || BODY="$(date) - ${2}"
|
||||||
[[ -z ${3} ]] && BODY="Service was restarted on $(date), please check your mailcow installation." || BODY="$(date) - ${3}"
|
WATCHDOG_NOTIFY_EMAIL=$(echo "${WATCHDOG_NOTIFY_EMAIL}" | sed 's/"//;s|"$||')
|
||||||
RCPT_DOMAIN=$(echo ${1} | awk -F @ {'print $NF'})
|
IFS=',' read -r -a MAIL_RCPTS <<< "${WATCHDOG_NOTIFY_EMAIL}"
|
||||||
RCPT_MX=$(dig +short ${RCPT_DOMAIN} mx | sort -n | awk '{print $2; exit}')
|
for rcpt in "${MAIL_RCPTS[@]}"; do
|
||||||
if [[ -z ${RCPT_MX} ]]; then
|
RCPT_DOMAIN=
|
||||||
log_msg "Cannot determine MX for ${1}, skipping email notification..."
|
RCPT_MX=
|
||||||
return 1
|
RCPT_DOMAIN=$(echo ${rcpt} | awk -F @ {'print $NF'})
|
||||||
fi
|
RCPT_MX=$(dig +short ${RCPT_DOMAIN} mx | sort -n | awk '{print $2; exit}')
|
||||||
[ -f "/tmp/${2}" ] && ATTACH="--attach /tmp/${2}@text/plain" || ATTACH=
|
if [[ -z ${RCPT_MX} ]]; then
|
||||||
./smtp-cli --missing-modules-ok \
|
log_msg "Cannot determine MX for ${rcpt}, skipping email notification..."
|
||||||
--subject="Watchdog: ${2} hit the error rate limit" \
|
return 1
|
||||||
--body-plain="${BODY}" \
|
fi
|
||||||
--to=${1} \
|
[ -f "/tmp/${1}" ] && ATTACH="--attach /tmp/${1}@text/plain" || ATTACH=
|
||||||
--from="watchdog@${MAILCOW_HOSTNAME}" \
|
./smtp-cli --missing-modules-ok \
|
||||||
--server="${RCPT_MX}" \
|
--subject="Watchdog: ${1} hit the error rate limit" \
|
||||||
--hello-host=${MAILCOW_HOSTNAME} \
|
--body-plain="${BODY}" \
|
||||||
${ATTACH}
|
--to=${rcpt} \
|
||||||
log_msg "Sent notification email to ${1}"
|
--from="watchdog@${MAILCOW_HOSTNAME}" \
|
||||||
|
--server="${RCPT_MX}" \
|
||||||
|
--hello-host=${MAILCOW_HOSTNAME} \
|
||||||
|
${ATTACH}
|
||||||
|
log_msg "Sent notification email to ${rcpt}"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_container_ip() {
|
get_container_ip() {
|
||||||
|
@ -312,7 +317,7 @@ Empty
|
||||||
while true; do
|
while true; do
|
||||||
if ! nginx_checks; then
|
if ! nginx_checks; then
|
||||||
log_msg "Nginx hit error limit"
|
log_msg "Nginx hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "nginx-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "nginx-mailcow"
|
||||||
echo nginx-mailcow > /tmp/com_pipe
|
echo nginx-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -323,7 +328,7 @@ BACKGROUND_TASKS+=($!)
|
||||||
while true; do
|
while true; do
|
||||||
if ! mysql_checks; then
|
if ! mysql_checks; then
|
||||||
log_msg "MySQL hit error limit"
|
log_msg "MySQL hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "mysql-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "mysql-mailcow"
|
||||||
echo mysql-mailcow > /tmp/com_pipe
|
echo mysql-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -334,7 +339,7 @@ BACKGROUND_TASKS+=($!)
|
||||||
while true; do
|
while true; do
|
||||||
if ! phpfpm_checks; then
|
if ! phpfpm_checks; then
|
||||||
log_msg "PHP-FPM hit error limit"
|
log_msg "PHP-FPM hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "php-fpm-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "php-fpm-mailcow"
|
||||||
echo php-fpm-mailcow > /tmp/com_pipe
|
echo php-fpm-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -345,7 +350,7 @@ BACKGROUND_TASKS+=($!)
|
||||||
while true; do
|
while true; do
|
||||||
if ! sogo_checks; then
|
if ! sogo_checks; then
|
||||||
log_msg "SOGo hit error limit"
|
log_msg "SOGo hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "sogo-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "sogo-mailcow"
|
||||||
echo sogo-mailcow > /tmp/com_pipe
|
echo sogo-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -357,7 +362,7 @@ if [ ${CHECK_UNBOUND} -eq 1 ]; then
|
||||||
while true; do
|
while true; do
|
||||||
if ! unbound_checks; then
|
if ! unbound_checks; then
|
||||||
log_msg "Unbound hit error limit"
|
log_msg "Unbound hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "unbound-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "unbound-mailcow"
|
||||||
echo unbound-mailcow > /tmp/com_pipe
|
echo unbound-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -370,7 +375,7 @@ if [[ "${SKIP_CLAMD}" =~ ^([nN][oO]|[nN])+$ ]]; then
|
||||||
while true; do
|
while true; do
|
||||||
if ! clamd_checks; then
|
if ! clamd_checks; then
|
||||||
log_msg "Clamd hit error limit"
|
log_msg "Clamd hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "clamd-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "clamd-mailcow"
|
||||||
echo clamd-mailcow > /tmp/com_pipe
|
echo clamd-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -382,7 +387,7 @@ fi
|
||||||
while true; do
|
while true; do
|
||||||
if ! postfix_checks; then
|
if ! postfix_checks; then
|
||||||
log_msg "Postfix hit error limit"
|
log_msg "Postfix hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "postfix-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "postfix-mailcow"
|
||||||
echo postfix-mailcow > /tmp/com_pipe
|
echo postfix-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -393,7 +398,7 @@ BACKGROUND_TASKS+=($!)
|
||||||
while true; do
|
while true; do
|
||||||
if ! dovecot_checks; then
|
if ! dovecot_checks; then
|
||||||
log_msg "Dovecot hit error limit"
|
log_msg "Dovecot hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "dovecot-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "dovecot-mailcow"
|
||||||
echo dovecot-mailcow > /tmp/com_pipe
|
echo dovecot-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -404,7 +409,7 @@ BACKGROUND_TASKS+=($!)
|
||||||
while true; do
|
while true; do
|
||||||
if ! rspamd_checks; then
|
if ! rspamd_checks; then
|
||||||
log_msg "Rspamd hit error limit"
|
log_msg "Rspamd hit error limit"
|
||||||
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${WATCHDOG_NOTIFY_EMAIL}" "rspamd-mailcow"
|
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "rspamd-mailcow"
|
||||||
echo rspamd-mailcow > /tmp/com_pipe
|
echo rspamd-mailcow > /tmp/com_pipe
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -338,7 +338,7 @@ services:
|
||||||
- /lib/modules:/lib/modules:ro
|
- /lib/modules:/lib/modules:ro
|
||||||
|
|
||||||
watchdog-mailcow:
|
watchdog-mailcow:
|
||||||
image: mailcow/watchdog:1.26
|
image: mailcow/watchdog:1.27
|
||||||
# Debug
|
# Debug
|
||||||
#command: /watchdog.sh
|
#command: /watchdog.sh
|
||||||
build: ./data/Dockerfiles/watchdog
|
build: ./data/Dockerfiles/watchdog
|
||||||
|
|
|
@ -125,6 +125,8 @@ SKIP_CLAMD=n
|
||||||
# Enable watchdog (watchdog-mailcow) to restart unhealthy containers (experimental)
|
# Enable watchdog (watchdog-mailcow) to restart unhealthy containers (experimental)
|
||||||
USE_WATCHDOG=n
|
USE_WATCHDOG=n
|
||||||
# Send notifications by mail (no DKIM signature, sent from watchdog@MAILCOW_HOSTNAME)
|
# Send notifications by mail (no DKIM signature, sent from watchdog@MAILCOW_HOSTNAME)
|
||||||
|
# Can by multiple rcpts, NO quotation marks
|
||||||
|
#WATCHDOG_NOTIFY_EMAIL=a@example.com,b@example.com,c@example.com
|
||||||
#WATCHDOG_NOTIFY_EMAIL=
|
#WATCHDOG_NOTIFY_EMAIL=
|
||||||
|
|
||||||
# Max log lines per service to keep in Redis logs
|
# Max log lines per service to keep in Redis logs
|
||||||
|
|
10
update.sh
10
update.sh
|
@ -114,7 +114,6 @@ CONFIG_ARRAY=(
|
||||||
"LOG_LINES"
|
"LOG_LINES"
|
||||||
"SNAT_TO_SOURCE"
|
"SNAT_TO_SOURCE"
|
||||||
"SNAT6_TO_SOURCE"
|
"SNAT6_TO_SOURCE"
|
||||||
"SYSCTL_IPV6_DISABLED"
|
|
||||||
"COMPOSE_PROJECT_NAME"
|
"COMPOSE_PROJECT_NAME"
|
||||||
"SQL_PORT"
|
"SQL_PORT"
|
||||||
"API_KEY"
|
"API_KEY"
|
||||||
|
@ -129,15 +128,6 @@ for option in ${CONFIG_ARRAY[@]}; do
|
||||||
echo "Adding new option \"${option}\" to mailcow.conf"
|
echo "Adding new option \"${option}\" to mailcow.conf"
|
||||||
echo "${option}=" >> mailcow.conf
|
echo "${option}=" >> mailcow.conf
|
||||||
fi
|
fi
|
||||||
elif [[ ${option} == "SYSCTL_IPV6_DISABLED" ]]; then
|
|
||||||
if ! grep -q ${option} mailcow.conf; then
|
|
||||||
echo "Adding new option \"${option}\" to mailcow.conf"
|
|
||||||
echo "# Disable IPv6" >> mailcow.conf
|
|
||||||
echo "# mailcow-network will still be created as IPv6 enabled, all containers will be created" >> mailcow.conf
|
|
||||||
echo "# without IPv6 support." >> mailcow.conf
|
|
||||||
echo "# Use 1 for disabled, 0 for enabled" >> mailcow.conf
|
|
||||||
echo "SYSCTL_IPV6_DISABLED=0" >> mailcow.conf
|
|
||||||
fi
|
|
||||||
elif [[ ${option} == "COMPOSE_PROJECT_NAME" ]]; then
|
elif [[ ${option} == "COMPOSE_PROJECT_NAME" ]]; then
|
||||||
if ! grep -q ${option} mailcow.conf; then
|
if ! grep -q ${option} mailcow.conf; then
|
||||||
echo "Adding new option \"${option}\" to mailcow.conf"
|
echo "Adding new option \"${option}\" to mailcow.conf"
|
||||||
|
|
Loading…
Reference in New Issue