Process & Resource Monitoring (Top/Htop/Ps/Systemd)
Unmasking Ghost Processes with Systemd Cgroup Accounting
🧩 The Challenge
Traditional monitoring tools often fail to capture resource usage for background processes that escape their parent service definition. It becomes difficult to see which specific unit is responsible for CPU or memory spikes when tasks spawn orphaned sub-processes.
💡 The Fix
Enable systemd resource accounting globally or per-service to force the kernel to track resource consumption directly within the unit control group. This ensures all spawned child processes are accounted for under the service’s cgroup regardless of their parentage.
systemctl set-property system.slice CPUAccounting=true MemoryAccounting=true
systemctl daemon-reload
systemd-cgtop
⚙️ Why It Works
By enabling accounting at the slice level, systemd forces every service process into a managed cgroup tree that provides accurate aggregation of resource usage. The systemd-cgtop utility then provides a live, top-like view filtered by these organized service hierarchies.
🚀 Pro-Tip: Use systemd-analyze blame to quickly identify which services contribute the most to your system boot time overhead.
Linux Tips & Tricks | © ngelinux.com | 7/11/2026
