#!/usr/bin/env bash # Run on rn-lab-host-01 (or the local dev machine running the Lab containers) WHILE # boot-labs.js is running, to capture real per-Lab CPU/RAM/disk usage — `docker stats` is the # ground truth here, not an estimate. Samples every 5s for the given duration and writes CSV. set -euo pipefail DURATION_SEC="${1:-120}" OUT="${2:-./results/resource-sample-$(date +%s).csv}" mkdir -p "$(dirname "$OUT")" echo "timestamp,container,cpu_pct,mem_usage,mem_pct,net_io,block_io,pids" > "$OUT" END=$(( $(date +%s) + DURATION_SEC )) while [ "$(date +%s)" -lt "$END" ]; do docker stats --no-stream --format '{{.Name}},{{.CPUPerc}},{{.MemUsage}},{{.MemPerc}},{{.NetIO}},{{.BlockIO}},{{.PIDs}}' \ | grep -E '^rootnode-lab-' \ | while IFS=, read -r name cpu mem memp net block pids; do echo "$(date -u +%Y-%m-%dT%H:%M:%SZ),$name,$cpu,$mem,$memp,$net,$block,$pids" >> "$OUT" done sleep 5 done echo "Written to $OUT" echo "Summarize with: awk -F, 'NR>1{print \$2}' $OUT | sort -u # containers seen"