Files
felhom.eu/documentation/audits/sizing-2026-10-13/tools/guest_sampler.sh
T
admin c885b5acf4 Audit: what a Felhom box needs — floor, 64 apps' memory and CPU, power (N100 bench); R-993..R-995; R-231 due check read green
Measured on demo-felhom (N100, 16 GB): 61 apps deployed and removed through the
product, sampled every 5 s; heavy apps with one real action (Immich 200 photos,
Jellyfin transcode, Paperless OCR, Nextcloud 500 MB, ...). sizing.json for the
estimator (tools/build_sizing.py), SIZING.md with the proposed minimum machine,
METHOD.md. Power is RAPL CPU-package only (no meter). R-993 asks the operator to
approve the minimum machine; R-994 lists catalog limits/requests that are too low;
R-995 records leftover unnamed volumes after removal. R-231's dated check measured:
dooplex-backup.service success, journal green.
2026-10-13 13:23:51 +02:00

25 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# guest_sampler.sh TAG — runs INSIDE the Felhom guest. Every 5 s, one line per running container:
# ts name mem_current anon inactive_file shmem cpu_usage_usec
# read straight from the container's cgroup v2 files (no docker stats: cheaper, and exact).
# Stops when /root/sizing/stop-TAG exists. Read-only: it writes only its own TSV.
TAG=${1:?tag}; D=/root/sizing; mkdir -p "$D"; OUT="$D/guest-$TAG.tsv"; rm -f "$D/stop-$TAG"
echo -e "ts\tname\tmem_current\tanon\tinactive_file\tshmem\tcpu_usage_usec" > "$OUT"
declare -A NAME; last=0
while [ ! -e "$D/stop-$TAG" ]; do
now=$(date +%s)
if (( now - last >= 30 )); then # refresh the id->name map every 30 s
NAME=(); while read -r id n; do NAME[$id]=$n; done < <(docker ps --no-trunc --format '{{.ID}} {{.Names}}')
last=$now
fi
for id in "${!NAME[@]}"; do
cg=/sys/fs/cgroup/system.slice/docker-$id.scope
[ -r "$cg/memory.current" ] || continue
cur=$(<"$cg/memory.current")
read -r anon inf shm < <(awk '$1=="anon"{a=$2} $1=="inactive_file"{i=$2} $1=="shmem"{s=$2} END{print a,i,s}' "$cg/memory.stat")
cpu=$(awk '$1=="usage_usec"{print $2}' "$cg/cpu.stat")
echo -e "$now\t${NAME[$id]}\t$cur\t$anon\t$inf\t$shm\t$cpu"
done >> "$OUT"
sleep 5
done