Site icon New Generation Enterprise Linux

Map your processes to their cgroup slices without guessing

Container Basics On Linux (Namespaces/Cgroups)

Map your processes to their cgroup slices without guessing

đź§© The Challenge

You’re staring at a high load average and `top` shows a mystery process eating cycles, but the cgroup hierarchy is so nested you can’t tell which container it actually belongs to. I’ve wasted way too much time grepping through `/sys/fs/cgroup` trying to figure out which pod or service is the culprit.

đź’ˇ The Fix

Use `ps` with custom output formatting to pull the cgroup path directly into your process list. It saves you from manual directory diving and keeps your sanity intact when debugging rogue containers.

ps -eo pid,user,cgroup,cmd --sort=-%cpu | head -n 20

⚙️ Why It Works

By explicitly asking the process table for the cgroup column, you force the kernel to bridge the gap between PID namespaces and the cgroup v2 hierarchy. It’s a clean way to see the exact slice a process resides in without hunting through filesystem paths.

🚀 Pro-Tip: Pipe this to `awk` to grab just the specific slice name if you’re dealing with deep Kubernetes nesting.

Linux Tips & Tricks | © ngelinux.com | 11/6/2026

0 0 votes
Article Rating
Exit mobile version