Created
May 10, 2026 22:11
-
-
Save koliadych/7d2456f93b8d599f8c699d23f1881d7d to your computer and use it in GitHub Desktop.
fintechner copy diag v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| export AWS_PAGER="" | |
| REGION=ap-northeast-1 | |
| INSTANCE_ID=i-089ad4a6b76132ba2 | |
| CMD_ID=$(aws --region "$REGION" ssm send-command \ | |
| --instance-ids "$INSTANCE_ID" \ | |
| --document-name AWS-RunShellScript \ | |
| --parameters '{"commands":[ | |
| "echo === copy_leaders ===", | |
| "sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT id, address, label, status, last_event_at FROM copy_leaders;\" 2>&1 | head -20", | |
| "echo", | |
| "echo === copy_policies ===", | |
| "sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT leader_id, enabled, sizing_mode, sizing_param, per_leader_cap_usd FROM copy_policies;\" 2>&1 | head -20", | |
| "echo", | |
| "echo === recent copy_decisions (10 newest) ===", | |
| "sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT ts, leader_id, decision, code, reason FROM copy_decisions ORDER BY ts DESC LIMIT 10;\" 2>&1 | head -25", | |
| "echo", | |
| "echo === copy_leader_events (latest 5) ===", | |
| "sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT ts, leader_id, side, coin, sz FROM copy_leader_events ORDER BY ts DESC LIMIT 5;\" 2>&1 | head -15" | |
| ]}' \ | |
| --query Command.CommandId --output text) | |
| for i in $(seq 1 20); do | |
| sleep 3 | |
| STATUS=$(aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query Status --output text 2>/dev/null || echo Pending) | |
| case "$STATUS" in Success|Failed|Cancelled|TimedOut) echo " $STATUS"; break ;; *) echo " $STATUS";; esac | |
| done | |
| echo | |
| aws --region "$REGION" ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query StandardOutputContent --output text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment