Files
proxmox/scripts/maintenance/diagnose-rpc-502s.sh
defiQUG 0d29343941 chore: update .env.master.example with new deployment scripts and treasury manager parameters; enhance AGENTS.md with GRU reference primacy details
- Added new deployment script references for Aave quote-push and treasury manager in .env.master.example.
- Updated AGENTS.md to include information on GRU reference primacy versus public PMM mesh execution model.
- Minor updates to various documentation files to reflect changes in policy and operational guidelines.

Made-with: Cursor
2026-04-12 18:20:41 -07:00

91 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Collect RPC diagnostics for selected core/edge RPC VMIDs: listening ports and Besu journal.
# Run from project root. Uses the shared live VMID placement map.
# Output is suitable for piping to a file or tee.
#
# Usage:
# ./scripts/maintenance/diagnose-rpc-502s.sh
# ./scripts/maintenance/diagnose-rpc-502s.sh --vmid 2101
# See: docs/00-meta/502_DEEP_DIVE_ROOT_CAUSES_AND_FIXES.md
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh"
SSH_OPTS="-o ConnectTimeout=8 -o StrictHostKeyChecking=accept-new"
TARGET_VMIDS=()
usage() {
cat <<'EOF'
Usage: ./scripts/maintenance/diagnose-rpc-502s.sh [--vmid <N>]
Options:
--vmid <N> Limit to one VMID; repeatable
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--vmid)
[[ $# -ge 2 ]] || { usage >&2; exit 2; }
TARGET_VMIDS+=("$2")
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
done
run() { ssh $SSH_OPTS "root@$1" "$2" 2>/dev/null || echo "(command failed or host unreachable)"; }
selected_vmid() {
local vmid="$1"
[[ ${#TARGET_VMIDS[@]} -eq 0 ]] && return 0
local wanted
for wanted in "${TARGET_VMIDS[@]}"; do
[[ "$vmid" == "$wanted" ]] && return 0
done
return 1
}
echo "=============================================="
echo "RPC 502 diagnostics — $(date -Iseconds)"
echo "=============================================="
echo ""
for vmid in 2101 2420 2430 2440 2460 2470 2480; do
selected_vmid "$vmid" || continue
host="$(get_host_for_vmid "$vmid")"
status=$(run "$host" "pct status $vmid 2>/dev/null | awk '{print \$2}'" || echo "unknown")
echo "--- VMID $vmid @ $host (status: $status) ---"
if [[ "$status" != "running" ]]; then
if [[ "$status" != "running" ]]; then
echo " Container not running. Skip."
echo ""
continue
fi
fi
echo " Listening ports (ss -tlnp):"
run "$host" "pct exec $vmid -- ss -tlnp 2>/dev/null" | sed 's/^/ /'
echo " Besu service (systemctl list-units):"
run "$host" "pct exec $vmid -- systemctl list-units --type=service --no-legend 2>/dev/null | grep -iE besu" | sed 's/^/ /'
for unit in besu-rpc besu; do
echo " journalctl -u $unit -n 25:"
run "$host" "pct exec $vmid -- journalctl -u $unit -n 25 --no-pager 2>/dev/null" | sed 's/^/ /'
done
echo ""
done
echo "=============================================="
echo "If 8545 is not in ss -tlnp, Besu is not binding. Check journal for genesis/nodekey/config errors."
echo "Then run: ./scripts/besu/fix-all-besu-nodes.sh --vmid <N> (optionally --no-restart first)"
echo "=============================================="