22 lines
981 B
Bash
Executable file
22 lines
981 B
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
# shellcheck disable=SC1091
|
|
. "$ROOT/cluster.env"
|
|
export PATH="/usr/sbin:/usr/bin:/bin:$PATH"
|
|
printf '%s\n' "$NODES" | awk 'NF==3 {print}' | while read -r vmid name ip; do
|
|
st="$(sudo pct status "$vmid" 2>/dev/null || echo missing)"
|
|
js="$(sudo pct exec "$vmid" -- curl -fsS --max-time 2 http://127.0.0.1:8222/varz 2>/dev/null || echo '{}')"
|
|
echo "$vmid $name $ip $st"
|
|
python3 -c "
|
|
import json,sys
|
|
try:
|
|
d=json.loads(sys.argv[1])
|
|
except Exception:
|
|
print(' nats down')
|
|
raise SystemExit
|
|
print(' server_name', d.get('server_name'), 'cluster', (d.get('cluster') or {}).get('name'), 'routes', len((d.get('cluster') or {}).get('urls') or d.get('connect_urls') or []))
|
|
print(' jetstream', bool(d.get('jetstream')), 'port', d.get('port'), 'host', d.get('host'))
|
|
" "$js" 2>/dev/null || echo " nats down"
|
|
done
|
|
echo "host loopback still: $(ss -lnt | grep '127.0.0.1:4222' && echo up || echo down)"
|