Tuning system performance using SAR in Linux

Source: Internet
Author: User
Tags cpu usage

Tuning system performance using SAR in Linux

Keywords: SAR

The SAR default is not installed under Linux, we need to install manually, it is generally recommended source mode installation, download similar sysstat-6.1.3.tar.gz

You can then use the Configure make make install.

Common formats for the SAR command line:

SAR [Options] [-A] [-o file] t [n]

In the command line, the N and t two parameters are combined to define the sampling interval and the number of times, T is the sampling interval, which must be
The parameters, n is the number of samples, is optional, the default value is 1,-o file means the command result in binary format
stored in a file, where filename is not a keyword and is a file name. Options is the command line option, the SAR command
There are a lot of options listed below, only the common options:

-A: The sum of all reports.
-U:CPU Utilization
-V: Process, I node, file, and lock table state.
-D: Hard drive usage report.
-r: No memory pages and hard disk blocks used.
-G: Serial I/O condition.
-B: Buffer usage.
-A: File read and write.
-C: System call condition.
-R: The activity of the process.
-Y: Terminal equipment activity situation.
-W: System Exchange activity.

An example is shown below.

Example one: Using the command line Sar-u T n

For example, sampling every 60 seconds, sampling 5 times in a row, observing CPU usage, and sampling results in binary
Form into the file Zhou in the current directory, type the following command:

# sar-u-O Zhou 60 5

Screen display:

SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001
14:43:50%usr%sys%wio%idle (-u)
14:44:50 0 1 4 94
14:45:50 0 2 4 93
14:46:50 0 2 2 96
14:47:50 0 2 5 93
14:48:50 0 2 2 96
Average 0 2 4 94

The contents of the display include:

%usr:cpu the percentage of time in user mode.
%sys:cpu the percentage of time in system mode.
%wio:cpu the percentage of time to wait for the input output to finish.
%IDLE:CPU idle time percentage.

In all the displays, we should mainly note that the values of%wio and%idle,%wio are too high, indicating that the hard disk has an I/O bottleneck
A high%idle value indicates that the CPU is idle and if the%idle value is high but the system responds slowly, it is possible that the CPU is waiting to allocate memory.
You should increase your memory capacity at this time. If the%idle value continues below 10, the system's CPU processing power is relatively low, and the table
The most necessary resource to solve in the Ming system is the CPU.

If you want to view the contents of the binary file Zhou, you need to type the following SAR command:

# sar-u-F Zhou

As a result, SAR commands can be sampled in real time and the results of previous samples can be queried.

Example two: Using the life line SAR-V T n

For example, sampling every 30 seconds, sampling 5 times in a row, observing the status of the core table, you need to type the following command:

# SAR-V 30 5

Screen display:
SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001
10:33:23 proc-sz ov Inod-sz ov File-sz ov Lock-sz (-V)
10:33:53 305/321 0 1337/2764 0 1561/1706 0 40/128
10:34:23 308/321 0 1340/2764 0 1587/1706 0 37/128
10:34:53 305/321 0 1332/2764 0 1565/1706 0 36/128
10:35:23 308/321 0 1338/2764 0 1592/1706 0 37/128
10:35:53 308/321 0 1335/2764 0 1591/1706 0 37/128

Display content includes:

Proc-sz: The number of table entries in the process table currently being used or allocated in the core, controlled by the core parameter max-proc.

Inod-sz: The number of table entries in the I node table currently being used or allocated in the core, by the core parameters
Max-inode control.

File-sz: The number of table entries in the file table currently in use or allocated in the core, controlled by the core parameters Max-file
System.

OV: The number of times the overflow occurred.

Lock-sz: The number of table entries that are being used or allocated in the core currently locked by the core parameter Max-flckre
Control.

Display format is

Actual use of table entries/number of table entries that can be used

Display content, core use is completely normal, three tables no overflow phenomenon, the core parameters do not need to adjust, such as
If the overflow occurs, the corresponding core parameters should be adjusted to increase the number of table entries.

Example three: Using the life line sar-d T n

For example, sampling every 30 seconds, sampling 5 consecutive times, reporting device usage, you need to type the following command:

# sar-d 30 5

Screen display:

SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001
11:06:43 device%busy avque r+w/s blks/s avwait avserv (-D)
11:07:13 wd-0 1.47 2.75 4.67 14.73 5.50 3.14
11:07:43 wd-0 0.43 18.77 3.07 8.66 25.11 1.41
11:08:13 wd-0 0.77 2.78 2.77 7.26 4.94 2.77
11:08:43 wd-0 1.10 11.18 4.10 11.26 27.32 2.68
11:09:13 wd-0 1.97 21.78 5.86 34.06 69.66 3.35
Average wd-0 1.15 12.11 4.09 15.19 31.12 2.80

Display content includes:

The Device:sar command is monitoring the name of the block device.
%busy: The percentage of time that the transfer request takes up when the device is busy.
Avque: The average number of requests not completed when the queue is full.
R+W/S: The amount of data transmitted to or from the device per second.
BLKS/S: Number of blocks transmitted per second, 512 bytes per block.
Avwait: The average time that the transmit request waits for the queue to be idle when the queue is full.
Avserv: The average time (in milliseconds) required to complete the transfer request.

In the displayed content, wd-0 is the name of the hard disk, the value of%busy is smaller, indicating the
Time too little, file system efficiency is not high, generally speaking,%busy value is higher, avque value is lower, file system
High efficiency, if the%busy and Avque values are relatively high, indicating that the hard drive transmission speed is too slow, need to adjust.

Example four: Using the life line Sar-b T n

For example, sampling every 30 seconds, sampling 5 times in a row, reporting the use of the buffer, you need to type the following command:

# Sar-b 30 5

Screen display:

SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001
14:54:59 bread/s lread/s%rcache bwrit/s lwrit/s%wcache pread/s pwrit/s (-B)
14:55:29 0 147 100 5 21 78 0 0
14:55:59 0 186 100 5 25 79 0 0
14:56:29 4 232 98 8 58 86 0 0
14:56:59 0 125 100 5 23 76 0 0
14:57:29 0 89 100 4 12 66 0 0
Average 1 156 99 5 28 80 0 0

Display content includes:

BREAD/S: The number of physical blocks per second read from the hard disk into the system buffer.
LREAD/S: The average number of logical blocks read from the system buffer per second.
%rcache: The percentage of logical reads in the buffer cache.
BWRIT/S: The average number of physical blocks written to disk per second from the system buffer.
LWRIT/S: The average number of logical blocks per second written to the system buffer.
%wcache: The percentage of logical reads in the buffer cache.
PREAD/S: The average number of physical reads requested per second.
PWRIT/S: The average number of physical writes per second requested.

In the content shown, the most important is the%cache and%wcache two columns, whose values reflect the use of the buffer
Rate, the value of%rcache is less than 90 or the value of%wcache is less than 65, the number of system buffer should be increased appropriately, buffer
The quantity is controlled by the core parameter nbuf, so that the%rcache reaches about 90 and the%wcache reaches about 80. But the buffer parameter
The value of how much impact I/O efficiency, increase buffer, should be in the case of large memory, otherwise system efficiency can not get
Improve.

Example five: using SAR-G t n

For example, sampling every 30 seconds, continuously sampling 5 times, reporting the operation of serial I/O, you need to type the following command:

# SAR-G 30 5

Screen display:

SCO_SV scosysv 3.2v5.0.5 i80386 11/22/2001
17:07:03 ovsiohw/s ovsiodma/s ovclist/s (-G)
17:07:33 0.00 0.00 0.00
17:08:03 0.00 0.00 0.00
17:08:33 0.00 0.00 0.00
17:09:03 0.00 0.00 0.00
17:09:33 0.00 0.00 0.00
Average 0.00 0.00 0.00

Display content includes:

OVSIOHW/S: Overflow in serial I/O hardware per second.

OVSIODMA/S: Overflow in the direct input/output channel cache per second for serial I/O.

OVCLIST/S: The overflow of character queues per second.

In the displayed content, the value of each column is zero, indicating that no serial I/O overflow occurred in the system during the sampling time
The phenomenon.

The use of SAR commands is many, sometimes judging a problem that requires several SAR commands to be used together, for example, suspicion
CPU bottlenecks, available sar-u and sar-q, suspect I/O bottlenecks, available sar-b, Sar-u, and
Sar-d, the above five cases are only a part of them, interested friends may wish to try.

This article from: ixpub Technical Community (www.ixpub.net) Detailed source reference: http://www.ixpub.net/thread-749930-1-17.html

Two The output of the Vmstat command is divided into six parts:

(1) Process procs:
R: The number of processes waiting in the run queue.
B: The number of processes waiting for IO.
(2) Memory Memoy:
SWPD: Current swap memory available (in kilobytes).
Free: Idle memory (in kilobytes).
Buff: The amount of memory to buffer (in kilobytes).
Cache: The amount of memory that is used as a cache (in kilobytes).
(3) Swap swap page
Si: The number of swap pages, in kb/seconds, from disk swap to memory.
So: the number of swap pages from memory swap to disk, in kb/seconds.
(4) IO block device:
BI: The number of blocks sent to the block device, in blocks per second.
Bo: The number of blocks received from the block device, in blocks per second.
(5) System:
In: Number of interrupts per second, including clock interrupts.
CS: The number of environment (context) switches per second.
(6) CPU central Processor:
CS: The time that the user process used. expressed as a percentage.
SY: The time that the system process was used. expressed as a percentage.
ID: The idle time of the central processing Unit. expressed as a percentage.
If R is often greater than 4 and the ID is often less than 40, it means that the CPU is heavily loaded. If the Bi,bo is not equal to 0 for a long time, it indicates that the physical memory capacity is too small.


This article is from the "16 Stage One Pit" blog, please be sure to keep this source http://tlinux.blog.51cto.com/7288656/1761183

Tuning system performance using SAR in Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.