Detailed explanation of SAR commands for Linux monitoring tools

Source: Internet
Author: User
Linux performance analysis sar command explanation SAR (system activity Reporter System Activity Report) is currently one of the most comprehensive system performance analysis tools in Linux. It can report system activities from multiple parties, including: file read/write, system call usage, disk I/O, CPU efficiency, memory usage, process activity and IPC-related activities.

Common sar command formats

SAR [Options] [-A] [-o file] T [N]

Where:

T indicates the sampling interval, and N indicates the number of samples. The default value is 1;

-O file: stores the command results in binary format. file is the file name.

Options is the command line option. Common options for SAR commands are as follows:

-A: total of all reports

-U: outputs CPU usage statistics

-V: outputs statistics of inode, files, and other kernel tables.

-D: outputs activity information for each block device, similar to iostat.

-R: Output memory and swap space statistics

-B: displays the I/O and transfer rate statistics.

-B: displays the swap between memory and "disk or swap space", and monitors the paging status.

-A: file read/write status

-C: output process statistics, number of processes created per second

-R: Output Memory Page statistics

-Y: terminal device activity

-W: Number of context switches per second

-W: Output System exchange activity information

1. CPU resource monitoring

For example, sample once every 10 seconds, sample three times in a row, observe the CPU usage, and save the sample result in binary format to the file test in the current directory. You need to enter the following command:

Sar-u-O test 10 3

The screen is shown as follows:

17:06:16 CPU % USER % nice % System % iowait % steal % idle

17:06:26 all 0.00 0.00 0.20 0.00 0.00

17:06:36 all 0.00 0.00 0.20 0.00 0.00

17:06:46 all 0.00 0.00 0.10 0.00 0.00

Average: All 0.00 0.00 0.17 0.00 0.00

Output description:

CPU: All indicates that the statistical information is the average value of all CPUs.

% USER: displays the percentage of total CPU usage at the user level (application.

% Nice: displays the percentage of the total CPU usage for nice operations at the user level.

% SYSTEM: Percentage of total CPU usage at the core level (kernel.

% Iowait: displays the percentage of CPU usage for I/O operations.

% Steal: the percentage of virtual CPUs waiting for hypervisor to provide services for another virtual process.

% Idle: displays the percentage of CPU consumed by idle time.

1. If % iowait is too high, it indicates that the hard disk has an I/O bottleneck.

2. If the value of % idle is high but the system response is slow, it may be that the CPU waits for memory allocation. In this case, the memory capacity should be increased.

3. If the value of % idle is lower than 1, the CPU processing capability of the system is relatively low, indicating that the most important resource to be solved in the system is the CPU.

To view the content in the binary file test, enter the following sar command:

Sar-u-F test

2. inode, file, and other kernel Table Monitoring

For example, if you sample the table every 10 seconds and sample the table three times in a row to observe the status of the core table, enter the following command:

Sar-V 10 3

The screen is shown as follows:

17:10:49 dentunusd file-Nr inode-Nr Pty-NR

17:10:59 6301 5664 12037 4

17:11:09 6301 5664 12037 4

17:11:19 6301 5664 12037 4

Average: 6301 5664 12037 4

Output description:

Dentunusd: number of unused entries in the directory Cache

File-Nr: the number of file handles used.

Inode-Nr: inode handle

Pty-Nr: Number of Pty used

3. Memory and swap space monitoring

For example, sampling is performed once every 10 seconds, and sampling is performed three times in a row. Monitoring memory paging:

Sar-R 10 3

The screen is shown as follows:

Output description:

Kbmemfree: this value is basically the same as the free value in the free command, so it does not include the buffer and cache space.

Kbmemused: this value is basically the same as the used value in the free command, so it includes the buffer and cache space.

% Memused: this value is a percentage of kbmemused and total memory (excluding swap.

Kbbuffers and kbcached: These two values are buffer and cache in the free command.

Kbcommit: Ensure the memory required by the current system, that is, the memory required to ensure no overflow (RAM + swap ).

% Commit: this value is a percentage of kbcommit and total memory (including swap.

4. Memory paging monitoring

For example, sampling is performed once every 10 seconds, and sampling is performed three times in a row. Monitoring memory paging:

Sar-B 10 3

The screen is shown as follows:

Output description:

Pgpgin/s: the number of bytes per second from disk or swap to memory (KB)

Pgpgout/s: the number of bytes per second from memory replacement to disk or swap (KB)

Fault/S: number of missing pages generated by the system per second, that is, the sum of the Primary and Secondary missing pages (Major + minor)

Majflt/S: Number of Primary missing pages per second.

Pgfree/S: Number of pages per second in the idle queue

Pgscank/S: Number of pages scanned by kswapd per second

Pgscand/S: number of directly scanned pages per second

Pgsteal/s: the number of pages that are cleared from the cache every second to meet memory requirements

% Vmeff: Percentage of pages cleared per second (pgsteal) to total scanning pages (pgscank + pgscand)

5. I/O and Transfer Rate Monitoring

For example, if you sample data every 10 seconds and sample data three times in a row to report the usage of the buffer, you need to enter the following command:

Sar-B 10 3

The screen is shown as follows:

18:51:05 TPS rtps wtps bread/s bwrtn/s

18:51:15 0.00 0.00 0.00 0.00 0.00

18:51:25 1.92 0.00 1.92 0.00 22.65

18:51:35 0.00 0.00 0.00 0.00 0.00

Average: 0.64 0.00 0.64 0.00 7.59

Output description:

TPS: the total amount of I/O transferred by physical devices per second

Rtps: Total amount of data read from physical devices per second

Wtps: Total amount of data written to the physical device per second

Bread/s: the amount of data read from the physical device per second. Unit: block/s.

Bwrtn/s: the volume of data written to the physical device per second. Unit: block/s.

6. Process queue length and average load Status Monitoring

For example, sample once every 10 seconds and sample three times in a row to monitor the length of the process queue and the average load status:

Sar-Q 10 3

The screen is shown as follows:

19:25:50 runq-SZ plist-SZ ldavg-1 ldavg-5 ldavg-15

19:26:00 0 259 0.00 0.00 0.00

19:26:10 0 259 0.00 0.00 0.00

19:26:20 0 259 0.00 0.00 0.00

Average: 0 259 0.00 0.00

Output description:

Runq-SZ: length of the running Queue (number of processes awaiting running)

Plist-SZ: Number of processes and threads in the Process List

Ldavg-1: average system load for the last minute (system load average)

Ldavg-5: average system load for the past 5 minutes

Ldavg-15: average system load for the past 15 minutes

7. Monitoring of system exchange activity information

For example, if sampling is performed once every 10 seconds and three consecutive sampling times, the monitoring system will exchange activity information:

Sar-W 10 3

The screen is shown as follows:

19:39:50 pswpin/s pswpout/s

19:40:00 0.00 0.00

19:40:10 0.00 0.00

19:40:20 0.00 0.00

Average: 0.00 0.00

Output description:

Pswpin/S: Number of swap pages per second

Pswpout/S: Number of swap pages generated by the system per second

8. device usage monitoring

For example, if you want to sample the device every 10 seconds for three consecutive times and report the device usage, enter the following command:

# Sar-D 10 3-P

The screen is shown as follows:

17:45:54 Dev TPS rd_sec/s wr_sec/s avgrq-SZ avgqu-SZ await svctm % util

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:46:04 SDA 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:46:04 vg_livedvd-lv_root 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:46:04 vg_livedvd-lv_swap 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Where:

Parameter-P can print out the SDA, HDC and other disk device names, if you do not have the parameter-P, the device node may be a dev8-0, dev22-0

TPS: the number of I/O requests from the physical disk per second. Multiple logical requests are merged into one I/O disk request. The size of one transmission is uncertain.

Rd_sec/S: Number of read sectors per second.

Wr_sec/S: Number of write sectors per second.

Avgrq-SZ: average data size (slice) of each device I/O operation ).

Avgqu-SZ: average length of the disk Request queue.

Await: Average time consumed by each request, from the request disk operation to the system processing, including the request queue waiting time, in milliseconds (1 second = 1000 milliseconds ).

Svctm: average time for the system to process each request, excluding the time consumed in the Request queue.

% Util: Percentage of I/O requests to CPU. The larger the ratio, the more saturated the request.

1. When avgqu-SZ is low, the utilization rate of the device is high.

2. When the value of % util is close to 100%, the bandwidth of the device is full.

To determine the system bottleneck, you sometimes need to combine several sar command options.

Suspected CPU bottlenecks, which can be viewed by SAR-U and Sar-Q.

Suspected memory bottlenecks, which can be viewed by SAR-B, Sar-R, and SAR-w.

I/O bottlenecks are suspected, which can be viewed by SAR-B, Sar-u, and SAR-D.

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.