#!/usr/bin/env bash # status.sh [data|crawl|all] — containers, health, published ports, host load/disk, backup timer. source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" sel="${1:-all}" targets=(); case "$sel" in all) targets=(data crawl) ;; data|crawl) targets=("$sel") ;; *) die "usage: status.sh [data|crawl|all]" ;; esac for t in "${targets[@]}"; do host="$(host_for "$t")" printf '\n%s══ %s (%s) ══%s\n' "$c_bold" "$t" "$host" "$c_rst" compose "$t" "ps --format 'table {{.Service}}\t{{.Status}}\t{{.Ports}}'" || warn "compose ps failed on $host" remote "$t" "echo; echo 'load:' \$(cut -d' ' -f1-3 /proc/loadavg) ' mem:' \$(free -g | awk '/Mem:/{print \$3\"/\"\$2\" GB\"}') ' disk /:' \$(df -h / | awk 'NR==2{print \$3\"/\"\$2\" (\"\$5\")\"}'); \ docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' 2>/dev/null | head -25" if [[ $t == data ]]; then remote data "curl -fsS -m 5 http://$DATA_WG_IP:8300/api/health && echo || echo 'edge /api/health: FAIL'" remote data "systemctl list-timers dci-backup.timer --no-pager 2>/dev/null | sed -n '1,2p'; ls -1t $BACKUP_DIR/pg 2>/dev/null | head -3 | sed 's/^/ last pg dumps: /'" else remote crawl "curl -fsS -m 5 http://$CRAWL_PRIVATE_IP:8320/healthz && echo || echo 'worker /healthz: FAIL'" fi done printf '\n%spublic:%s ' "$c_bold" "$c_rst"; curl -fsS -m 10 "$PUBLIC_URL/api/health" 2>/dev/null && echo || echo "$PUBLIC_URL/api/health unreachable"