Using systemd resource accounting
systemd resource accounting is a feature that allows you to monitor and control the usage of system resources, such as CPU and memory, by individual services and processes.
One of the most common types of resource accounting is CPU accounting, which allows you to measure the amount of CPU time used by a specific service or process. This is accomplished by using the CPUAccounting=true option in the service’s systemd unit file.