SPB Git forge
38commits 1branches 0releases
338.7 MBsize
maindefault branch
3 h agolast push
HTML 53.9% TypeScript 44.5% JavaScript 0.6% SQL 0.5%
1.4 KB · 21 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# status.sh [data|crawl|all]  — containers, health, published ports, host load/disk, backup timer.3source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"4sel="${1:-all}"5targets=(); case "$sel" in all) targets=(data crawl) ;; data|crawl) targets=("$sel") ;; *) die "usage: status.sh [data|crawl|all]" ;; esac67for t in "${targets[@]}"; do8  host="$(host_for "$t")"9  printf '\n%s══ %s (%s) ══%s\n' "$c_bold" "$t" "$host" "$c_rst"10  compose "$t" "ps --format 'table {{.Service}}\t{{.Status}}\t{{.Ports}}'" || warn "compose ps failed on $host"11  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\")\"}'); \12    docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' 2>/dev/null | head -25"13  if [[ $t == data ]]; then14    remote data "curl -fsS -m 5 http://$DATA_WG_IP:8300/api/health && echo || echo 'edge /api/health: FAIL'"15    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: /'"16  else17    remote crawl "curl -fsS -m 5 http://$CRAWL_PRIVATE_IP:8320/healthz && echo || echo 'worker /healthz: FAIL'"18  fi19done20printf '\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"21