#!/bin/bash # relay-health-check.sh — check all four CDP relay endpoints on bl. # Self-contained: no nested SSH quoting. Sources pinned ports from netvm-names.sh. # # Output: "name:code" per relay on stdout. # Exit 0 if all return 200; exit 1 otherwise (lists failures on stderr). # # Called by the cdp-relay-health-monitor cron and by `box-ctl.py relay-health`. set -u SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=/dev/null source "$SCRIPT_DIR/netvm-names.sh" FAILED=0 for node in muse pip 646 opm; do netvm_names "$node" url="http://${PEER_IP}:${CDP_PORT}/json/version" code=$(curl -s -m 8 -o /dev/null -w "%{http_code}" "$url" 2>/dev/null || echo "000") echo "${node}:${code}" if [ "$code" != "200" ]; then echo "FAIL: ${node} relay ${PEER_IP}:${CDP_PORT} returned ${code}" >&2 FAILED=1 fi done exit $FAILED