(Transfer) System maintenance in UNIX with SAR commands

zhaozj2021-02-16  62

In the process of using the UNIX operating system, we often use a variety of problems, such as the system running suddenly slow, the system is easy to crash or the terminal belongs to the terminal often crashed, and we often guess the hard disk. Is space too small or insufficient memory? I / O appears bottlenecks, or the core parameters of the system have problems? At this time, we should consider the use of the system to give us the SAR command to make a understanding of the system, which is an important tool for system maintenance, mainly to help us master the usage of system resources, especially the use of memory and CPU, is One of the tools that UNIX systems should master. SAR command line common format:

SAR [options] [-a] [-o file] t [n]

In the command line, the two parameters of n and t are combined to define the sampling interval and the number of times, and the sampling interval is a must-have parameter, n is the number of samples, which is optional, the default value is 1, -o file representation The command results are stored in the file in a two-in format, and the file is not a keyword here. It is the file name. Options is a command line option, the SAR command has a lot of options, and only common options are listed below:

-A: The sum of all reports. -U: CPU utilization -V: process, i node, file, and lock status. -D: Hard disk use report. -R: There is no memory page and hard disk block. -G: The case of serial port I / O. -b: Buffer usage. -A: File read and write conditions. -c: System call condition. -R: The activity of the process. -y: Terminal equipment activity. -w: System exchange activities.

The following will be an example.

Example 1: Use the command line SAR -U T N

For example, sampling every 60 seconds, continuously sampling 5 times, observing the use of the CPU, and stores the sample results in binary form in the current directory in the current directory, you need to 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

In the display, including:

% USR: The time percentage of the CPU is in user mode. % SYS: CPU is in system mode for time percentage. % Wio: CPU Wait for the percentage of input and output completion time. % IDLE: CPU free time percentage.

In all the display, we should mainly pay attention to the% WIO and% IDLE, the% WIO value is too high, indicating that the hard disk has I / O bottleneck,% IDLE value, indicating that the CPU is free, if the% IDLE value is high but the system responds slow When it is possible that the CPU is waiting to allocate memory, and the memory capacity should be increased. The% IDLE value is relatively low if the system's CPU processing capability is relatively low, and the resources most solved in the system are the CPU. If you want to see the contents in binary zhou, you need to type the following SAR command:

# sar -u -f zhou

It can be seen that the SAR command can be sampled in real time, and the previous sampling result can be queried.

Example 2: Using Direct SAR -V T N

For example, sampling once every 30 seconds, continuously sampling 5 times, 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

The display includes:

Proc-SZ: The number of items of the process table that is currently using or allocated in the core is controlled by the core parameter MAX-PROC.

Inod-sz: The number of item INOD tables in the current core is currently in use or allocated by the core parameter MAX-INODE.

FILE-SZ: The number of items of the file table that is in use or allocated in the core is controlled by the core parameter Max-File.

OV: Overflows the number of occurrences.

LOCK-SZ: The number of items that are locked or allocated in the current core is controlled by the core parameter MAX-FLCKRE.

Display format

The actual number of entries / items that can be used

The display content indicates that the core is completely normal, and the three tables do not have an overflow. The core parameters do not need to be adjusted. If there is an overflow, the corresponding core parameters are adjusted, and the corresponding number of items should be increased.

Example 3: Using Direct SAR-D T N

For example, samples every 30 seconds, continuously sample 5 times, report the 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 includes:

Device: The SAR command is being monitored by the name of the block device. % Busy: When the device is busy, the percentage of the time to transfer the request. AVQUE: The average of the request quantity is not completed when the queue station is full. R W / S: The amount of data sent from the device or from the device per second. BLKS / S: The number of blocks transmitted per second, 512 bytes per block. Avwait: The queue is sent to the average time to wait for the queue idle. AVSERV: The average time (milliseconds) required to complete the transfer request.

In the displayed content, the WD-0 is the name of the hard disk, and the value of% BUSY is relatively small, which means that there is too little time for processing the transfer request, the file system is not high, generally, the% busy value is higher, Avque The value is low, the efficiency of the file system is relatively high, if the% busy and AVQue values ​​are relatively high, indicating that the hard disk transfer speed is too slow and needs to be adjusted.

Example 4: Using Direct SAR -B T N

For example, sampling every 30 seconds, continuously sampling 5 times, reporting the usage 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

The display includes:

BREAD / S: The number of physical blocks of the system buffer buffer is read from the hard disk per second. LREAD / S: The number of logical blocks read from the system buffer per second. % rcache: Percentage of logically read in Buffer Cache. BWRIT / S: The number of physical blocks written from the system buffer per second. LWRIT / S: Write an average of the number of system Buffer logic blocks per second. % WCache: Percentage of logically read in Buffer Cache. PREAD / S: Average the number of times of physical reading per second. PWRIT / S: The average number of times of physical writing is requested per second. In the displayed content, the% cache and% wcache are two columns, and their values ​​reflect the efficiency of the buffer, the value of the% RCache is less than 90 or the value of the value of the WCache is less than 65, and the number of system buffers should be appropriately increased The number of buffers is controlled by the core parameter NBUF, so that% rcache reaches 90 or so,% WCache reaches around 80. However, the Buffer parameter value affects I / O efficiency, increasing the buffer, should not improve the system efficiency in the case of large memory, otherwise the system efficiency is not improved.

Example 5: Using Direct SAR -G T N

For example, sampling every 30 seconds, continuously sampling 5 times, reporting the operation of serial port I / O, try 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

The display includes:

OvsioHW / S: Overflows in serial port I / O hardware per second.

OvsiODMA / S: Overflows from the direct input / output channel cache per second in serial port I / O.

OvClist / s: overflows appear per second character queue.

In the displayed content, the value of each column is zero, indicating that the serial port I / O overflow occurs in the system in the sampling time.

There are a lot of usage, sometimes a problem, need a few SAR commands, such as, suspect that the CPU has bottlenecks, can be seen in SAR -U and SAR -Q, suspected of I / O, bottleneck, available SAR -B, SAR -U and SAR-D come see, the five mentioned above are just some of them, interested friends may wish to try.

转载请注明原文地址:https://www.9cbs.com/read-15477.html

New Post(0)