There are really two main possibilities that may be limiting your performance in Linux. This document is written to take you through the process of discovering where the bottleneck is on Redhat or CentOS, but it should work on most other versions of Linux as well.
A GOOD PLACE TO START – THE TOP
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. The top command monitors CPU utilization, process statistics, and memory utilization. The top section contains information related to overall system status – uptime, load average, process counts, CPU status, and utilization statistics for both memory and swap space.
WANT TO SEE THE INDIVIDUAL PROCESSES?
You can use the command mpstat -P ALL, to get this output, but I like a new tool called HTOP
yum install htop
Then just run it with ‘htop’ on the command line. You will see all the CPUs at the top of the screen.
NOT AS USEFUL
Try SAR. The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters.
I don’t like sar as much, but you can build a log file by redirecting the output to
nohup sar -o output.file 12 8 >/dev/null 2>&1 &
WHO ARE THE CPU EATERS
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
WHO ARE THE CPU EATERS
What kind of throughput am I getting on the ethernet connection?
yum install iptraf
The iostat command kind of rocks when checking for disk and partition usage.
iostat -d -x 2
will cause a display of juicy data to appear. The command above is going to display the data every two seconds so you may want to resize the window to handle the refresh gracefully.
What does it all mean?
Well, the last three columns are the most important. And note: as %util approaches 100% the device or partition is approaching saturation.
- rrqm/s : The number of read requests merged per second that were queued to the hard disk
- wrqm/s : The number of write requests merged per second that were queued to the hard disk
- r/s : The number of read requests per second
- w/s : The number of write requests per second
- rsec/s : The number of sectors read from the hard disk per second
- wsec/s : The number of sectors written to the hard disk per second
- avgrq-sz : The average size (in sectors) of the requests that were issued to the device.
- avgqu-sz : The average queue length of the requests that were issued to the device
- await : The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
- svctm : The average service time (in milliseconds) for I/O requests that were issued to the device
- %util : Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.
PUTTING IT ALL TOGETHER
Realistically, if you call up htop you can monitor the CPU usage. Call up iostat to see the disk i/o. That will give you are real time reading of what is happening.
About Jay Farschman - Jay currently works as a Senior Systems Administrator for an asset management company in Colorado where he works with companies that produce hardware, telecommunications software and financial services. Jay previously owned a consulting company and provided training and consulting services for three Fortune 500 companies and numerous small businesses where he leveraged Linux to provided exceptional value.
Share on Facebook