#!/bin/bash # Mempool MariaDB health check — managed by Ansible (roles/mempool) # The exit code is the answer; systemd keeps it. Reporting is optional. PUSH_URL="${HEALTHCHECK_PUSH_URL:-}" check() { {% raw %} [ "$(docker inspect --format='{{.State.Health.Status}}' mempool-db 2>/dev/null)" = "healthy" ] {% endraw %} } report() { # No push URL is normal, not an error. The previous version logged # "ERROR: UPTIME_KUMA_PUSH_URL not set" on every fire, once a minute. [ -n "$PUSH_URL" ] || return 0 curl -s --max-time 10 --retry 2 -o /dev/null \ "${PUSH_URL}?status=$1&msg=${2// /%20}&ping=" || true } if check; then report up "OK"; exit 0 else echo "MariaDB container unhealthy"; report down "MariaDB container unhealthy"; exit 1; fi