#!/bin/bash # The deadman: the one check that does not depend on the observability stack being alive. # # vmalert and Alertmanager tell you when something on the box is wrong. Nothing inside that chain can tell you # the chain itself is down, and silence looks exactly like health. So this runs on the HOST from a systemd # timer, uses nothing but curl, and posts straight to a Discord webhook. # # It checks three things: # 1. every piece of the stack answers its health endpoint # 2. Alertmanager's Watchdog heartbeat is fresh (proves rule evaluation AND routing work end to end, # not merely that the processes are up) # 3. the disks, because that is the failure this box is most likely to die of, and it must be reported # even when the thing that would normally report it is the thing that broke # # State in /var/lib/vanguard/deadman.state: it announces a change, not the same thing every five minutes, # and says so once when everything recovers. set -uo pipefail WEBHOOK_FILE="${ALERT_WEBHOOK_FILE:-/etc/vanguard/alert-webhook}" HEARTBEAT="${ALERT_HEARTBEAT_FILE:-/srv/media/.markers/alert-heartbeat}" HEARTBEAT_MAX_S="${HEARTBEAT_MAX_S:-600}" STATE="${DEADMAN_STATE:-/var/lib/vanguard/deadman.state}" DISK_PCT="${DEADMAN_DISK_PCT:-90}" problems=() note() { problems+=("$1"); } alive() { # alive