Summary of the SAR tool commands in Linux

Source: Internet
Author: User

SAR was originally an internal tool, which can be downloaded at http://pagesperso-orange.fr/sebastien.godard/download.html.

 

1 Installation
Tar zxvf xxx.tar.gz

./Configure

Make

Make install

 

2. Use
Pidstat 2   5  
// Displays the CPU usage of all active processes 5 times every 2 seconds.
Pidstat - P 3132   2   5  
// The CPU usage of processes whose PID is 3132 is displayed 5 times every 2 seconds.
Pidstat - P 3132   2   5   - R
// The memory usage of processes with a PID of 3132 is displayed 5 times every 2 seconds.

View CPU usage

SAR 2   5
// Displays 5 times of CPU usage every 2 seconds

 

% USR: Percentage of CPU time in user mode.
% SYS: Percentage of CPU time in system mode.
% WIO: Percentage of CPU waiting for input/output completion time.
% Idle: Percentage of idle CPU time.

In all the displays, we should pay attention to % WIO and % idle. The value of % WIO is too high, indicating that the hard disk has an I/O bottleneck,
The % idle value is high, indicating that the CPU is idle. If the % idle value is high but the system response is slow, the CPU may wait for memory allocation,
In this case, the memory capacity should be increased. % If the idle value is lower than 10, the CPU processing capability of the system is relatively low.
The most important resource in the system is the CPU.

SAR 1   10   > Data.txt
// Write Data every 1second and save the CPU usage data to the data.txt file.
SAR 1   0   - E 15 : 00 : 00   > Data.txt
// The CPU usage is recorded every 1second, and the data is saved to the data.txt file. (The-e parameter indicates the end time. Note that the time format must be hh: mm: Ss)
SAR 1   0   - R - E 15 : 00 : 00   > Data.txt
// The memory usage is recorded every 1second, and the data is saved to the data.txt file.
SAR 1   0   - N Dev - E 15 : 00 : 00   > Data.txt
// The network usage is recorded every 1second, and the data is saved to the data.txt file.

 

Example 2: Use alive Sar-V T N

For example, if you sample data every 30 seconds for five consecutive times and observe the status of the core table, enter 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 displayed content includes:

Proc-SZ: Number of table items in the table currently being used or allocated in the core, controlled by the core parameter MAX-PROC.

Inod-SZ: the number of table items in the I-node table that are currently being used or allocated in the core.
MAX-INODE control.

File-SZ: Number of table items in the file table currently being used or allocated in the core, controlled by the core parameter MAX-FILE
.

Ov: the number of overflow times.

Lock-SZ: Number of table items that are currently being locked by or allocated records in the core, with the core parameter MAX-FLCKRE
Control.

The display format is

Actual use of table items/number of available table items

The displayed content indicates that the core is completely normal. The three tables do not have overflow and the core parameters do not need to be adjusted, as shown in figure
If overflow occurs, adjust the corresponding core parameters to increase the number of corresponding table items.

Example 3: Use life-line Sar-d t n

For example, if you want to sample the device every 30 seconds for five consecutive times and report the device usage, enter 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

The displayed content includes:

Device: the name of the block device being monitored by the sar command.
% Busy: percentage of requests sent when the device is busy.
Avque: the average number of incomplete requests when the queue is full.
R + w/s: the amount of data transferred to or from the device per second.
Blks/s: the number of transferred blocks per second, each of which is 512 bytes.
Avwait: the average time for sending requests to wait for the queue to be idle when the queue is full.
Avserv: Average time (in milliseconds) required to complete the transfer request ).

In the displayed content, the wd-0 is the name of the hard disk and % busy is smaller, indicating that
The efficiency is too small, and the file system efficiency is not high. Generally, the % busy value is higher, the avque value is lower, and the file system
If the % busy and avque values are relatively high, the hard disk transmission speed is too slow and needs to be adjusted.

Example 4: Use alive Sar-B T N

For example, if you sample the buffer every 30 seconds for five consecutive times and report the usage of the buffer, enter 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
4 14:56:29 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 displayed content includes:

Bread/s: the number of physical blocks read from the hard disk to the System Buffer per second.
Lread/s: the average number of logical blocks read from the System Buffer per second.
% Rcache: Percentage of logical reads in buffer cache.
Bwrit/S: Average number of physical blocks written from the system buffer to the disk per second.
Lwrit/S: Average number of logical blocks written to the System Buffer per second.
% Wcache: Percentage of logical reads in buffer cache.
Pread/S: Average number of physical reads requested per second.
Pwrit/S: Average number of physical writes requested per second.

In the displayed content, the most important columns are % cache and % wcache. Their values reflect the buffer usage efficiency.
Rate, % rcache value is less than 90 or % wcache value is less than 65, should increase the number of System Buffer, Buffer
The number is controlled by the core parameter nbuf, so that % rcache reaches 90, and % wcache reaches 80. But the buffer Parameter
The value affects the I/O efficiency and increases the buffer. The large memory size should be applied; otherwise, the system efficiency will not be available.
Improve.

Example 5: Use alive Sar-G T N

For example, if you want to sample data every 30 seconds for five consecutive times and report the serial I/O operations, enter 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 displayed content includes:

Ovsiohw/S: serial port I/O hardware overflow per second.

Ovsiodma/S: overflow in the cache of the direct input/output channel of the serial port I/O per second.

Ovclist/S: overflow of character queues per second.

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

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.