forked from mtusi2026/mtusi2026lab3
The first run of series A was spoiled by other stands on the same Docker VM: an image build of another lab is invisible to docker stats, yet it took CPU from the pinned replicas, doubled their CPU per request and stalled the Docker API for fifteen minutes in the middle of two steps. docker-stats.sh now also samples the VM-wide /proc/stat counters, so a step records the CPU of the whole VM, the part not used by this project, the largest gap between samples and its wall time. A step with more than one foreign core, a gap over 10 s or a k6 run 90 s longer than its load is written to disturbed.csv and repeated after the VM has been quiet for 15 s, up to three times. On a quiet VM the foreign part is 2 % of a core at 600 rps and 25 % at 4 560 rps, which is Docker networking and the samplers themselves. The growth series starts at 300 rps per CPU and searches up to 9 000, so its knees are found with fewer idle steps. The plots fit the universal scalability law to the growth series. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
|