#!/usr/bin/env bash set -euo pipefail BASE_URL="${1:-http://127.0.0.1:8100}" NODE_CODE="${2:-}" LIMIT="${3:-80}" MODE="${4:-key}" CURL_CONNECT_TIMEOUT="${CURL_CONNECT_TIMEOUT:-3}" CURL_MAX_TIME="${CURL_MAX_TIME:-8}" if [[ -z "${NODE_CODE}" ]]; then echo "usage: bash domain-api/deploy/multi-region/check_node_scene_log.sh [base_url] [limit] [key|full]" >&2 exit 1 fi RAW_RESPONSE="$(curl -sS \ --connect-timeout "${CURL_CONNECT_TIMEOUT}" \ --max-time "${CURL_MAX_TIME}" \ "${BASE_URL}/api/v1/ops/nodes/${NODE_CODE}/scene-log?limit=${LIMIT}&mode=${MODE}")" echo "[1/2] raw response" printf '%s\n\n' "${RAW_RESPONSE}" echo "[2/2] condensed scene-log summary" python3 - "${RAW_RESPONSE}" <<'PY' import json import sys raw = str(sys.argv[1] or "") payload = json.loads(raw) data = dict(payload.get("data") or {}) participation = dict(data.get("participation") or {}) source_summary = dict(data.get("source_summary") or {}) records = list(data.get("records") or []) latest = dict(data.get("latest_record") or {}) summary = { "node_code": str(data.get("node_code") or ""), "status": str(data.get("status") or ""), "status_label": str(data.get("status_label") or ""), "mode": str(data.get("mode") or ""), "summary": str(data.get("summary") or ""), "log_sync_enabled": bool(data.get("log_sync_enabled", False)), "records_total": int(data.get("records_total", len(records)) or 0), "missing_reason_code": str(data.get("missing_reason_code") or ""), "participation": { "detect_participating": bool(participation.get("detect_participating", False)), "participation_state": str(participation.get("participation_state") or ""), "participation_label": str(participation.get("participation_label") or ""), "participation_reason": str(participation.get("participation_reason") or ""), "current_load": int(participation.get("current_load", 0) or 0), }, "source_summary": { "line_count": int(source_summary.get("line_count", 0) or 0), "key_line_count": int(source_summary.get("key_line_count", 0) or 0), "full_line_count": int(source_summary.get("full_line_count", 0) or 0), "last_at": str(source_summary.get("last_at") or ""), "last_line": str(source_summary.get("last_line") or ""), }, "latest_record": latest, "sample_messages": [str(item.get("message") or "") for item in records[:8]], } print(json.dumps(summary, ensure_ascii=False, indent=2)) PY