ce2a10e995
gates / gates (push) Successful in 27s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
13 lines
947 B
Bash
Executable File
13 lines
947 B
Bash
Executable File
# sampler.sh (run INSIDE the bench or the box): sample the cgroup of each named container from its birth, every 2 s.
|
|
# usage: NAMES="a b c" OUT=/root/mem.csv DUR=900 bash sampler.sh & — stops at DUR or when $OUT.stop exists
|
|
: > $OUT; t0=$(date +%s)
|
|
while [ $(( $(date +%s) - t0 )) -lt ${DUR:-900} ] && [ ! -f $OUT.stop ]; do
|
|
for n in $NAMES; do
|
|
id=$(docker ps -q --no-trunc --filter name=^$n$ | head -1); [ -z "$id" ] && continue
|
|
cg=$(ls -d /sys/fs/cgroup/system.slice/docker-$id.scope 2>/dev/null || find /sys/fs/cgroup -maxdepth 4 -type d -name "*$id*" 2>/dev/null | head -1)
|
|
[ -f "$cg/memory.stat" ] || continue
|
|
echo "$(date +%s),$n,${id:0:12},$(awk '$1=="anon"{print $2}' $cg/memory.stat),$(cat $cg/memory.current),$(cat $cg/memory.swap.current 2>/dev/null || echo NA),$(awk '$1=="oom_kill"{print $2}' $cg/memory.events),$(cat $cg/memory.max),$(docker inspect -f '{{.RestartCount}}' $id)" >> $OUT
|
|
done
|
|
sleep 2
|
|
done
|