Chapter 2. Monitoring and benchmark tools 51
Draft Document for Review May 4, 2007 11:35 am 4285ch02.fm
Example 2-15 Displaying system statistics with sar
[root@linux sa]# sar -n DEV -f sa21 | less
Linux 2.6.9-5.ELsmp (linux.itso.ral.ibm.com) 04/21/2005
12:00:01 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
12:10:01 AM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth0 1.80 0.00 247.89 0.00 0.00 0.00 0.00
12:10:01 AM eth1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
You can also use sar to run near-real-time reporting from the command line (Example2-16).
Example 2-16 Ad hoc CPU monitoring
[root@x232 root]# sar -u 3 10
Linux 2.4.21-9.0.3.EL (x232) 05/22/2004
02:10:40 PM CPU %user %nice %system %idle
02:10:43 PM all 0.00 0.00 0.00 100.00
02:10:46 PM all 0.33 0.00 0.00 99.67
02:10:49 PM all 0.00 0.00 0.00 100.00
02:10:52 PM all 7.14 0.00 18.57 74.29
02:10:55 PM all 71.43 0.00 28.57 0.00
02:10:58 PM all 0.00 0.00 100.00 0.00
02:11:01 PM all 0.00 0.00 0.00 0.00
02:11:04 PM all 0.00 0.00 100.00 0.00
02:11:07 PM all 50.00 0.00 50.00 0.00
02:11:10 PM all 0.00 0.00 100.00 0.00
Average: all 1.62 0.00 3.33 95.06
From the collected data, you see a detailed overview of CPU utilization (%user, %nice,
%system, %idle), memory paging, network I/O and transfer statistics, process creation
activity, activity for block devices, and interrupts/second over time.
2.3.8 mpstat
The mpstat command is used to report the activities of each of the available CPUs on a
multiprocessor server. Global average activities among all CPUs are also reported. The
mpstat utility is part of the sysstat package.
The mpstat utility enables you to display overall CPU statistics per system or per processor.
mpstat also enables the creation of statistics when used in sampling mode analogous to the
vmstat command with a sampling frequency and a sampling count. Example2-17 shows a
sample output created with mpstat -P ALL to display average CPU utilization per processor.
Example 2-17 Output of mpstat command on multiprocessor system
[root@linux ~]# mpstat -P ALL
Linux 2.6.9-5.ELsmp (linux.itso.ral.ibm.com) 04/22/2005
03:19:21 PM CPU %user %nice %system %iowait %irq %soft %idle intr/s
03:19:21 PM all 0.03 0.00 0.34 0.06 0.02 0.08 99.47 1124.22
03:19:21 PM 0 0.03 0.00 0.33 0.03 0.04 0.15 99.43 612.12
03:19:21 PM 1 0.03 0.00 0.36 0.10 0.01 0.01 99.51 512.09