[Watchdog] More fixes for watchdog...

master
andryyy 2019-08-13 20:19:01 +02:00
parent 294e0bc07f
commit f00b563d9c
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
3 changed files with 6 additions and 14 deletions

View File

@ -33,6 +33,7 @@ RUN apk add --update \
COPY watchdog.sh /watchdog.sh COPY watchdog.sh /watchdog.sh
ENTRYPOINT ["/sbin/tini", "-g", "--"] #ENTRYPOINT ["/sbin/tini", "-g", "--"]
# Less verbose # Less verbose
CMD /watchdog.sh 2> /dev/null CMD /watchdog.sh 2> /dev/null

View File

@ -529,19 +529,11 @@ olefy_checks() {
} }
# Notify about start # Notify about start
if [[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && [[ ! -f /tmp/watchdog_reload ]]; then if [[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]]; then
mail_error "watchdog-mailcow" "Watchdog started monitoring mailcow." mail_error "watchdog-mailcow" "Watchdog started monitoring mailcow."
rm /tmp/watchdog_reload
fi fi
# Create watchdog agents # Create watchdog agents
(
touch /tmp/watchdog_reload
sleep 86400
echo "Reloading watchdog"
killall watchdog
kill 1
) &
( (
while true; do while true; do
@ -759,15 +751,14 @@ while true; do
log_msg "acme-mailcow did not complete successfully" log_msg "acme-mailcow did not complete successfully"
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${com_pipe_answer}" "Please check acme-mailcow for further information." [[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && mail_error "${com_pipe_answer}" "Please check acme-mailcow for further information."
elif [[ ${com_pipe_answer} == "fail2ban" ]]; then elif [[ ${com_pipe_answer} == "fail2ban" ]]; then
F2B_RES=($(redis-cli -h redis-mailcow --raw GET F2B_RES)) F2B_RES=($(timeout 4s redis-cli -h redis-mailcow --raw GET F2B_RES 2> /dev/null))
if [[ ! -z "${F2B_RES}" ]]; then if [[ ! -z "${F2B_RES}" ]]; then
redis-cli -h redis-mailcow DEL F2B_RES > /dev/null redis-cli -h redis-mailcow DEL F2B_RES > /dev/null
host= host=
for host in "${F2B_RES[@]}"; do for host in "${F2B_RES[@]}"; do
log_msg "Banned ${host}" log_msg "Banned ${host}"
rm /tmp/fail2ban 2> /dev/null rm /tmp/fail2ban 2> /dev/null
timeout 2s whois ${host} > /tmp/fail2ban timeout 2s whois "${host}" > /tmp/fail2ban
sleep 2.5
[[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && [[ ${WATCHDOG_NOTIFY_BAN} =~ ^([yY][eE][sS]|[yY])+$ ]] && mail_error "${com_pipe_answer}" "IP ban: ${host}" [[ ! -z ${WATCHDOG_NOTIFY_EMAIL} ]] && [[ ${WATCHDOG_NOTIFY_BAN} =~ ^([yY][eE][sS]|[yY])+$ ]] && mail_error "${com_pipe_answer}" "IP ban: ${host}"
done done
fi fi

View File

@ -366,7 +366,7 @@ services:
- /lib/modules:/lib/modules:ro - /lib/modules:/lib/modules:ro
watchdog-mailcow: watchdog-mailcow:
image: mailcow/watchdog:1.55 image: mailcow/watchdog:1.56
# Debug # Debug
#command: /watchdog.sh #command: /watchdog.sh
build: ./data/Dockerfiles/watchdog build: ./data/Dockerfiles/watchdog