
Note that you need to provide the interval parameter (e.g., 5) which specifies the amount of time in seconds between each report. The %usr and %system columns indicate how much of the CPU is executed in the user space or in the kernel, respectively. The CPU field next to %CPU denotes the CPU processor ID to which the process is attached (in case there are more than one CPU processors on your system). The output indicates that the process consumes 5.5% of a single CPU core on average. If you press Ctrl-C, the command will exit and print the overall average CPU usage. This command will refresh the average CPU usage every five second. In this example, I am measuring the average CPU usage of a Linux process with PID 11579, which is measured over five-second interval. Once you have installed sysstat, you can use pidstat to measure the average CPU usage of a Linux process as follows. Measure Average CPU Usage of a Process with pidstat

If the sysstat package is not available on your Linux system, you can easily build it from the source as follows.

Install sysstat on Ubuntu, Debian or Linux Mint $ sudo apt install sysstat Install sysstat on CentOS, RHEL or Fedora $ sudo yum install sysstat Build sysstat from the Source

In order to use pidstat, you need to install the sysstat package as follows. In the following let's find out how to measure the average CPU utilization of a particular Linux process, or process-level CPU usage of all available Linux processes with pidstat tool. One of the utilities contained in sysstat is pidstat, which can measure the average CPU usage of Linux processes. For this purpose, a Linux tool set called sysstat may come in handy, which contains a collection of performance monitoring tools for Linux, reporting statistics on disk I/O, CPU, memory, networking, and other system activities. As the CPU usage of a process can fluctuate over its lifetime, you will want to measure the average CPU usage or CPU utilization of the process.

Sometimes you may want to know the CPU usage of a particular Linux process. How to measure the average CPU utilization of a Linux process
