#!/usr/bin/env bash set -euo pipefail ssh -o BatchMode=yes eventhub-ift bash -s <<'REMOTE' set -euo pipefail cd /opt/ai-router-stack set -a; source .env; set +a PG=$(docker ps -q -f name=ai-router_postgres | head -1) echo "== Tokens/users now ==" docker exec -e PGPASSWORD="$POSTGRES_PASSWORD" "$PG" \ psql -U "${POSTGRES_USER:-litellm}" -d "${POSTGRES_DB:-litellm}" -c " SELECT count(*) AS tokens FROM \"LiteLLM_VerificationToken\"; SELECT count(*) AS users FROM \"LiteLLM_UserTable\"; SELECT \"user_id\", \"user_role\" FROM \"LiteLLM_UserTable\" LIMIT 5; " echo "== Master key models probe ==" code=$(curl -sS -o /tmp/m.json -w "%{http_code}" --max-time 20 \ -H "Authorization: Bearer ${LITELLM_MASTER_KEY}" \ https://litellm.ift.calentiq.com/v1/models) echo "models HTTP $code" head -c 120 /tmp/m.json; echo echo "== Flush redis key cache (best effort) ==" RID=$(docker ps -q -f name=ai-router_redis | head -1) if [[ -n "$RID" ]]; then docker exec "$RID" redis-cli KEYS '*token*' 2>/dev/null | head -20 || true docker exec "$RID" redis-cli KEYS '*litellm*' 2>/dev/null | head -20 || true # do not FLUSHALL — may kill router session cache; only clear litellm-ish if safe fi echo DONE REMOTE