Skip to content

Instantly share code, notes, and snippets.

@koliadych
Created May 11, 2026 07:07
Show Gist options
  • Select an option

  • Save koliadych/f80cd96f9edfdc6c23bd78b8bca22b52 to your computer and use it in GitHub Desktop.

Select an option

Save koliadych/f80cd96f9edfdc6c23bd78b8bca22b52 to your computer and use it in GitHub Desktop.
fintechner full status inventory
#!/bin/bash
# fintechner — live inventory of the deployed system.
set -euo pipefail
export AWS_PAGER=""
REGION=ap-northeast-1
INSTANCE_ID=i-089ad4a6b76132ba2
echo "============================================================"
echo " AWS-side"
echo "============================================================"
echo
echo "--- EC2 ---"
aws --region "$REGION" ec2 describe-instances --instance-ids "$INSTANCE_ID" \
--query 'Reservations[0].Instances[0].{state:State.Name,type:InstanceType,az:Placement.AvailabilityZone,launchTime:LaunchTime,publicIp:PublicIpAddress,disableTermination:`null`}' \
--output table 2>&1 | head -20
echo
echo " termination-protection: $(aws --region $REGION ec2 describe-instance-attribute --instance-id $INSTANCE_ID --attribute disableApiTermination --query 'DisableApiTermination.Value' --output text)"
echo
echo "--- Budgets ---"
aws --region us-east-1 budgets describe-budgets --account-id $(aws sts get-caller-identity --query Account --output text) \
--query 'Budgets[].{name:BudgetName,limit:BudgetLimit.Amount}' --output table 2>&1 | head -8
echo
echo "--- Secrets ---"
aws --region "$REGION" secretsmanager list-secrets --query 'SecretList[?starts_with(Name,`fintechner/`)].{name:Name,lastUpdated:LastChangedDate}' --output table 2>&1 | head -15
echo
echo "--- DLM snapshot policy ---"
aws --region "$REGION" dlm get-lifecycle-policies --query 'Policies[?Description==`fintechner-daily-7`].{id:PolicyId,state:State}' --output table 2>&1
echo
echo "============================================================"
echo " On the EC2 box"
echo "============================================================"
CMD_ID=$(aws --region "$REGION" ssm send-command \
--instance-ids "$INSTANCE_ID" \
--document-name AWS-RunShellScript \
--parameters 'commands=["echo --- services ---","for s in caddy fintechner-connector fintechner-dashboard; do printf \"%-25s %s\\n\" \"$s\" \"$(sudo systemctl is-active $s)\"; done","sudo docker ps --format \"timescale {{.Status}}\"","echo","echo --- connector commit ---","sudo sha256sum /opt/fintechner/bin/connector | cut -c1-16","echo","echo --- DB row counts ---","sudo docker exec timescale psql -U fintechner -d fintechner -tA -c \"SELECT \"users:\"||COUNT(*) FROM users UNION ALL SELECT \"hl_credentials:\"||COUNT(*) FROM hl_credentials UNION ALL SELECT \"strategy_configs:\"||COUNT(*) FROM strategy_configs UNION ALL SELECT \"orders:\"||COUNT(*) FROM orders UNION ALL SELECT \"fills:\"||COUNT(*) FROM fills UNION ALL SELECT \"copy_leaders:\"||COUNT(*) FROM copy_leaders UNION ALL SELECT \"copy_policies (enabled):\"||COUNT(*) FROM copy_policies WHERE enabled=true UNION ALL SELECT \"copy_policies (disabled):\"||COUNT(*) FROM copy_policies WHERE enabled=false UNION ALL SELECT \"closed_trades:\"||COUNT(*) FROM closed_trades;\"","echo","echo --- last 3 orders ---","sudo docker exec timescale psql -U fintechner -d fintechner -c \"SELECT cloid, coin, side, status, submitted_at FROM orders ORDER BY submitted_at DESC LIMIT 3;\""]' \
--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) break ;; esac
done
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