System information

18 System Analysis and Tuning Guide
With the -P option, you can specify the number of processors to be reported (note
that 0 is the first processor). The timing arguments work the same way as with the
iostat command. Entering mpstat -P 1 2 5 prints five reports for the second
processor (number 1) at 2 second intervals.
tux@mercury:~> mpstat -P 1 2 5
Linux 2.6.32.7-0.2-default (geeko@buildhost) 02/24/10 _x86_64_
08:57:10 CPU %usr %nice %sys %iowait %irq %soft %steal \
%guest %idle
08:57:12 1 4.46 0.00 5.94 0.50 0.00 0.00 0.00 \
0.00 89.11
08:57:14 1 1.98 0.00 2.97 0.99 0.00 0.99 0.00 \
0.00 93.07
08:57:16 1 2.50 0.00 3.00 0.00 0.00 1.00 0.00 \
0.00 93.50
08:57:18 1 14.36 0.00 1.98 0.00 0.00 0.50 0.00 \
0.00 83.17
08:57:20 1 2.51 0.00 4.02 0.00 0.00 2.01 0.00 \
0.00 91.46
Average: 1 5.17 0.00 3.58 0.30 0.00 0.90 0.00 \
0.00 90.05
2.2.3 Task Monitoring: pidstat
If you need to see what load a particular task applies to your system, use pidstat
command. It prints activity of every selected task or all tasks managed by Linux ker-
nel if no task is specified. You can also set the number of reports to be displayed and
the time interval between them.
For example, pidstat -C top 2 3 prints the load statistic for tasks whose com-
mand name includes the string “top”. There will be three reports printed at two second
intervals.
tux@mercury:~> pidstat -C top 2 3
Linux 2.6.27.19-5-default (geeko@buildhost) 03/23/2009 _x86_64_
09:25:42 AM PID %usr %system %guest %CPU CPU Command
09:25:44 AM 23576 37.62 61.39 0.00 99.01 1 top
09:25:44 AM PID %usr %system %guest %CPU CPU Command
09:25:46 AM 23576 37.00 62.00 0.00 99.00 1 top
09:25:46 AM PID %usr %system %guest %CPU CPU Command
09:25:48 AM 23576 38.00 61.00 0.00 99.00 1 top
Average: PID %usr %system %guest %CPU CPU Command
Average: 23576 37.54 61.46 0.00 99.00 - top