pub fn build_cgroup_sampler_start_snippet(container_name: &str) -> StringExpand description
Shell fragment starting the background sampler. It writes each sample to a
temp file with mv, so the watcher never reads a half-written line, and
ends by itself once the container is gone.
Where the cgroup is readable locally it reads it directly. Otherwise, with
a private cgroup namespace (a mounted docker.sock), one long-lived
docker exec -i answers one host tick per interval (issue #242); a
successful read proves the container runs, so Docker is asked for liveness
only after a failed round or when the stream ends. Without a usable stream it falls back
to one docker exec per round; without sh in the image (exit 126/127) or
without any readable cgroup (exit 3 from either exec, issue #247) it
records the reason and stops. Other failed rounds are retried, each one
doubling the wait up to CGROUP_SAMPLE_BACKOFF_MAX_SECONDS; a sample
restores the interval. START_COMMAND_CGROUP_SAMPLE_INTERVAL_SECONDS=off
disables sampling.