- Reset master to upstream/main (16,697 commits) - Overlay 2,271 local-only files (skills, tools, workspace, configs, apps) - Restore IDENTITY.md and USER.md templates - Build verified, gateway running, Discord working Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
1.6 KiB
Bash
72 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# summarize.sh <samples.csv>
|
|
# Produces a quick text summary + per-endpoint aggregates.
|
|
|
|
csv="${1:-}"
|
|
if [[ -z "$csv" || ! -f "$csv" ]]; then
|
|
echo "Usage: summarize.sh <path/to/samples.csv>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
# CSV columns (see monitor.sh):
|
|
# 1 ts_utc
|
|
# 2 tick
|
|
# 3 endpoint_idx
|
|
# 4 url (JSON string)
|
|
# 5 http_status
|
|
# 6 total_time_ms
|
|
|
|
awk -F',' '
|
|
NR==1 {next}
|
|
{
|
|
idx=$3;
|
|
status=$5;
|
|
ms=$6;
|
|
# url is JSON string (quoted); keep raw
|
|
url=$4;
|
|
|
|
count[idx]++;
|
|
sum_ms[idx]+=ms;
|
|
if (!(idx in min_ms) || ms < min_ms[idx]) min_ms[idx]=ms;
|
|
if (!(idx in max_ms) || ms > max_ms[idx]) max_ms[idx]=ms;
|
|
|
|
url_by_idx[idx]=url;
|
|
|
|
status_count[idx, status]++;
|
|
total++;
|
|
if (status ~ /^2/) ok++;
|
|
else if (status ~ /^3/) redir++;
|
|
else if (status ~ /^4/) c4++;
|
|
else if (status ~ /^5/) c5++;
|
|
else other++;
|
|
}
|
|
END {
|
|
print "Samples:", total;
|
|
print "2xx:", ok, "3xx:", redir, "4xx:", c4, "5xx:", c5, "other:", other;
|
|
print "";
|
|
|
|
# Per endpoint
|
|
print "Per-endpoint aggregates:";
|
|
for (idx in count) {
|
|
avg = (count[idx] ? sum_ms[idx]/count[idx] : 0);
|
|
printf("- idx=%s url=%s\n", idx, url_by_idx[idx]);
|
|
printf(" n=%d avg_ms=%.1f min_ms=%d max_ms=%d\n", count[idx], avg, min_ms[idx], max_ms[idx]);
|
|
|
|
# print top statuses seen
|
|
printf(" statuses:");
|
|
first=1;
|
|
for (k in status_count) {
|
|
split(k, parts, SUBSEP);
|
|
if (parts[1]==idx) {
|
|
if (!first) printf(",");
|
|
printf(" %s=%d", parts[2], status_count[k]);
|
|
first=0;
|
|
}
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|
|
' "$csv"
|