Carry source f591fa64e525679a31c9db7f942d36c789e1a12f forward from 72a1e57. Preserve lab4 attachment transactions, reconciliation locks, quarantine, and existing schema data through verified legacy adoption. Keep report and evidence work in progress untouched.
16 lines
778 B
Bash
Executable File
16 lines
778 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
out=${1:?usage: docker-stats.sh <csv>}
|
|
vm=$(dirname "$out")/vm_stat.csv
|
|
cd "$(dirname "$0")/.."
|
|
project=$(docker compose config | sed -n 's/^name: //p')
|
|
echo 'ts,name,cpu_pct,mem_usage,mem_pct,net_io,block_io,pids' > "$out"
|
|
echo 'ts,busy,total,cpus' > "$vm"
|
|
while :; do
|
|
ts=$(date +%s)
|
|
docker compose exec -T valkey cat /proc/stat 2>/dev/null | awk -v ts="$ts" '/^cpu /{b=$2+$3+$4+$7+$8+$9; t=b+$5+$6} /^cpu[0-9]/{n++} END{if (t) print ts "," b "," t "," n}' >> "$vm" || true
|
|
ids=$(docker ps -q --filter "label=com.docker.compose.project=$project")
|
|
[ -z "$ids" ] || docker stats --no-stream --format "$ts,{{.Name}},{{.CPUPerc}},{{.MemUsage}},{{.MemPerc}},{{.NetIO}},{{.BlockIO}},{{.PIDs}}" $ids >> "$out" || true
|
|
sleep "${INTERVAL:-1}"
|
|
done
|