73 lines
2.4 KiB
Bash
Executable File
73 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
BASE_URL="${1:-http://127.0.0.1:8100}"
|
|
CURL_CONNECT_TIMEOUT="${CURL_CONNECT_TIMEOUT:-3}"
|
|
CURL_MAX_TIME="${CURL_MAX_TIME:-10}"
|
|
|
|
curl_json() {
|
|
curl -fsS \
|
|
--connect-timeout "${CURL_CONNECT_TIMEOUT}" \
|
|
--max-time "${CURL_MAX_TIME}" \
|
|
"$1"
|
|
}
|
|
|
|
INSPECTION_JSON="$(curl_json "${BASE_URL}/api/v1/ops/inspection-overview?limit=120")"
|
|
|
|
echo "[1/5] inspection overview"
|
|
printf '%s\n\n' "${INSPECTION_JSON}"
|
|
|
|
echo "[2/5] condensed summary"
|
|
python3 - <<'PY' "${INSPECTION_JSON}"
|
|
import json
|
|
import sys
|
|
|
|
payload = json.loads(sys.argv[1]).get("data") or {}
|
|
print(json.dumps({
|
|
"rows_total": int(payload.get("rows_total") or 0),
|
|
"filtered_rows_total": int(payload.get("filtered_rows_total") or 0),
|
|
"visible_nodes_total": int(payload.get("visible_nodes_total") or 0),
|
|
"eligible_nodes_total": int(payload.get("eligible_nodes_total") or 0),
|
|
"handover_gap_nodes_total": int(payload.get("handover_gap_nodes_total") or 0),
|
|
"participating_nodes_total": int(payload.get("participating_nodes_total") or 0),
|
|
"summary": dict(payload.get("summary") or {}),
|
|
"available_problem_kind_counts": dict(payload.get("available_problem_kind_counts") or {}),
|
|
"filters": dict(payload.get("filters") or {}),
|
|
}, ensure_ascii=False, indent=2))
|
|
PY
|
|
echo
|
|
|
|
echo "[3/5] priority queue"
|
|
python3 - <<'PY' "${INSPECTION_JSON}"
|
|
import json
|
|
import sys
|
|
|
|
payload = json.loads(sys.argv[1]).get("data") or {}
|
|
rows = list(payload.get("priority_queue") or [])
|
|
print(json.dumps({
|
|
"total": len(rows),
|
|
"items": [
|
|
{
|
|
"node_code": str(item.get("node_code") or ""),
|
|
"overall_status": str(item.get("overall_status") or ""),
|
|
"problem_kind": str(item.get("problem_kind") or ""),
|
|
"problem_label": str(item.get("problem_label") or ""),
|
|
"recommended_action_code": str(item.get("recommended_action_code") or ""),
|
|
"last_updated_at": str(item.get("last_updated_at") or ""),
|
|
"issue_summary": str(item.get("issue_summary") or ""),
|
|
}
|
|
for item in rows[:12]
|
|
],
|
|
}, ensure_ascii=False, indent=2))
|
|
PY
|
|
echo
|
|
|
|
echo "[4/5] attention only"
|
|
curl_json "${BASE_URL}/api/v1/ops/inspection-overview?limit=80&status=attention&only_problem=true"
|
|
echo
|
|
echo
|
|
|
|
echo "[5/5] participating problems only"
|
|
curl_json "${BASE_URL}/api/v1/ops/inspection-overview?limit=80&only_problem=true&only_participating=true"
|
|
echo
|