linux

Page 217

82935c10.qxd:Toolbox

10/29/07

1:15 PM

Page 192

Chapter 10: Managing the System avg-cpu: avg-cpu: avg-cpu: avg-cpu:

%user 0.50 %user 28.71 %user 98.99 %user 99.50

%nice 0.00 %nice 0.00 %nice 0.00 %nice 0.00

%system 0.00 %system 5.45 %system 1.01 %system 0.50

%iowait 0.00 %iowait 18.32 %iowait 0.00 %iowait 0.00

%steal 0.00 %steal 0.00 %steal 0.00 %steal 0.00

%idle 99.50 %idle 47.52 %idle 0.00 %idle 0.00

$ iostat -c 3 CPU stats every 3 seconds (copying files) Linux 2.6.21-1.3194.fc7 (davinci) 08/10/2007 avg-cpu: %user %nice %system %iowait %steal %idle 0.50 0.00 0.00 0.00 0.00 0.00 avg-cpu: %user %nice %system %iowait %steal %idle 0.50 0.00 24.88 74.63 0.00 0.00 avg-cpu: %user %nice %system %iowait %steal %idle 0.50 0.00 10.00 89.50 0.00 0.00 avg-cpu: %user %nice %system %iowait %steal %idle 0.50 0.00 17.41 82.09 0.00 0.00 avg-cpu: %user %nice %system %iowait %steal %idle 0.00 0.00 14.65 85.35 0.00 0.00

The first iostat example above starts with a quiet system, then several applications started up. You can see that most of the processing to start the applications is being done in user space. The second iostat example shows a case where several large files are copied from one hard disk to another. The result is a high percentage of time being spent at the system level, also known as kernel space (in this case, reading from and writing to disk partitions). Note that the file copies also result in a higher amount of time waiting for I/O requests to complete (%iowait). Here are examples using iostat to print CPU utilization reports with timestamps: $ iostat -c -t Print time stamp with CPU report Linux 2.6.21-1.3194.fc7 (davinci) 08/10/2007 Time: 9:28:03 AM avg-cpu: %user %nice %system %iowait %steal %idle 0.50 0.00 0.00 0.00 0.00 99.50 $ iostat -c -t 2 10 Repeat every 2 seconds for 10 times

The dstat command (dstat package) is available as an alternative to iostat for viewing information about your CPU usage (as well as other performance-related items). One advantage of dstat over other tools is that it more precisely shows the units of measurement it is displaying (such as kilobytes or megabytes) and also uses colors to differentiate the data. Here is an example of dstat for displaying CPU information: $ dstat -t -c 3 View CPU usage continuously with time stamps ---time--- ----total-cpu-usage---__epoch___|usr sys idl wai hiq siq 1189727284| 0 0 100 0 0 0 1189727287| 1 0 99 0 0 0

192


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.