81 lines
2.8 KiB
Bash
Executable File
81 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
MAINLAND_BASE_URL="${1:-http://127.0.0.1:8100}"
|
|
OVERSEAS_BASE_URL="${2:-http://152.53.37.118:8100}"
|
|
PYTHON_BIN="${PYTHON_BIN:-python3}"
|
|
|
|
echo "[1/6] mainland readiness"
|
|
MAINLAND_READINESS="$(curl -fsS "${MAINLAND_BASE_URL}/api/v1/runtime/readiness")"
|
|
echo "${MAINLAND_READINESS}"
|
|
echo
|
|
echo
|
|
|
|
echo "[2/6] mainland sync summary"
|
|
MAINLAND_SYNC="$(curl -fsS "${MAINLAND_BASE_URL}/api/v1/runtime/sync-summary")"
|
|
echo "${MAINLAND_SYNC}"
|
|
echo
|
|
echo
|
|
|
|
echo "[3/6] mainland push sync"
|
|
MAINLAND_PUSH="$(curl -fsS -X POST "${MAINLAND_BASE_URL}/api/v1/runtime/actions/push_sync")"
|
|
echo "${MAINLAND_PUSH}"
|
|
echo
|
|
echo
|
|
|
|
echo "[4/6] overseas cluster"
|
|
OVERSEAS_CLUSTER="$(curl -fsS "${OVERSEAS_BASE_URL}/api/v1/runtime/cluster")"
|
|
echo "${OVERSEAS_CLUSTER}"
|
|
echo
|
|
echo
|
|
|
|
echo "[5/6] overseas sync summary"
|
|
OVERSEAS_SYNC="$(curl -fsS "${OVERSEAS_BASE_URL}/api/v1/runtime/sync-summary")"
|
|
echo "${OVERSEAS_SYNC}"
|
|
echo
|
|
echo
|
|
|
|
echo "[6/6] condensed summary"
|
|
"${PYTHON_BIN}" - <<'PY' "$MAINLAND_READINESS" "$MAINLAND_SYNC" "$MAINLAND_PUSH" "$OVERSEAS_CLUSTER" "$OVERSEAS_SYNC"
|
|
import json
|
|
import sys
|
|
|
|
mainland_readiness = json.loads(sys.argv[1]).get("data", {})
|
|
mainland_sync = json.loads(sys.argv[2]).get("data", {})
|
|
mainland_push = json.loads(sys.argv[3])
|
|
overseas_cluster = json.loads(sys.argv[4]).get("data", {})
|
|
overseas_sync = json.loads(sys.argv[5]).get("data", {})
|
|
|
|
cluster_nodes = overseas_cluster.get("nodes") or []
|
|
cluster_summary = overseas_cluster.get("summary") or {}
|
|
type_counts = overseas_sync.get("type_counts") or {}
|
|
status_counts = overseas_sync.get("status_counts") or {}
|
|
|
|
print(
|
|
json.dumps(
|
|
{
|
|
"mainland": {
|
|
"readiness_status": mainland_readiness.get("status", ""),
|
|
"readiness_summary": mainland_readiness.get("summary", ""),
|
|
"sync_enabled": bool(mainland_sync.get("enabled", False)),
|
|
"target_api_base_url": mainland_sync.get("target_api_base_url", ""),
|
|
"push_sync_code": mainland_push.get("code"),
|
|
"push_sync_message": mainland_push.get("message", ""),
|
|
},
|
|
"overseas": {
|
|
"nodes_total": overseas_cluster.get("nodes_total", 0),
|
|
"online_control_nodes": cluster_summary.get("online_control_nodes", 0),
|
|
"online_worker_nodes": cluster_summary.get("online_worker_nodes", 0),
|
|
"node_codes": [str(item.get("node_code") or "") for item in cluster_nodes],
|
|
"runtime_ingest": type_counts.get("runtime_ingest", 0),
|
|
"detect_result_ingest": type_counts.get("detect_result_ingest", 0),
|
|
"status_received": status_counts.get("received", 0),
|
|
"status_success": status_counts.get("success", 0),
|
|
},
|
|
},
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
)
|
|
PY
|