cpustat - a tool to measure CPU utilization.
[ options ] [delay
cpustat is a program that dumps the CPU utilization of current running tasks
(that is, processes or kernel threads). cpustat is useful to monitor the
activity of long lived processes in a system, such as daemons, kernel threads
as well as typical user processes.
cpustat shows only the tasks that have measured any change in their CPU activity
between each sample interval (as indicated by an increment in the CPU tick
count stats of utime and stime in /proc/$pid/stat). cpustat thus only reports
activity of busy tasks that are still alive at the time of each sample
snapshot and hence will not account for very short lived processes that exist
between each sample period.
For each running task that has consumed some CPU during the sample time, the
following information is displayed:
||Total CPU used (in percent)
||CPU used in user space (in percent)
||CPU used in system (kernel) space (in percent)
||CPU used by the process at time of sampling.
||Total CPU time used by the process since it started.
||Process command line information (from process cmdline or comm
cpustat was designed to try and minimize the CPU overhead of process statistics
gathering and reporting. It is therefore ideal for small embedded devices
where CPU is limited where measuring CPU utilisation may affect the overall
CPU statistics. For this reason, it is not as complex as tools such as top(1)
that have a more feature rich user interface.
||Waiting, Disk Sleep
|X or x
cpustat options are as follow:
- calculate CPU utilisation based on all CPUs. For example,
if a process is using 100% of 1 CPU and the system has 4 CPUs, then the
utilisation will show as 25%. The default is to show utilisation on a per
- get command information from process comm field.
- strip directory basename off command information.
- compute and show the distribution of CPU utilisation by
task and by CPU.
By task, this breaks the CPU utilisation of each task into 20 ranges from
minimum to the maximum and shows the count of tasks found at in that
paricular utilisation range. Useful to see any outliers and to
characterize the typical per task usage of the CPU.
By CPU, this shows the user and system CPU utilisation by per CPU.
- show grand total of CPU utilisation statistics at the end
of the run. This is the total cumulatave CPU used by each process,
averaged over the entire run duration.
- show help.
- ignore cpustat in the statistics.
- show long (full) command information.
- -n task_count
- only display the first task_count number of top tasks.
- -p PID
- only display process that matches the given PID.
- run quietly, only really makes sense with -r option.
- -r csv_file
- output gathered data in a comma separated values file. This
can be then imported and graphed using your favourite open source spread
sheet. The %CPU utilisation (system and user) for each process at each
sample time is output into a table.
- show short command information.
- show time stamp. If the -r option is used then an extra
column appears in the CSV output file with the time of day for each
- -t threshold
- ignore samples where the CPU usage delta per second less
than the given threshold.
- calculate total CPU utilisation.
- show extra CPU related statistics, namely: CPU load average
over 1, 5 and 10 minutes, CPU frequency (average of all online CPU
frequencies), number of CPUs online.
- run in curses based "top" like mode; this will
make cpustat consume more CPU cycles as it adds on more display handling
- Dump CPU stats every second until stopped.
cpustat -n 20 60
- Dump the top 20 CPU consuming tasks every 60 seconds until
cpustat 10 5
- Dump CPU stats every 10 seconds just 5 times.
cpustat -x -D -a 1 300
- Gather stats every second for 5 minutes with extra CPU
stats and show CPU utilisation distributions per task and per CPU at the
end of the run. Also, scale CPU utilisation by the number of CPUs so that
100% utilisation means 100% of all CPUs rather than 100% of 1 CPU.
cpustat was written by Colin King <firstname.lastname@example.org>
This manual page was written by Colin King <email@example.com>, for
the Ubuntu project (but may be used by others).
Copyright © 2011-2017 Canonical Ltd.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR