Linux uses SAR for performance analysis

Source: Internet
Author: User

Ext.: 54606401#sar%e7%ae%80%e4%bb%8b

Linux uses SAR for performance analysis

    • Linux uses SAR for performance analysis
      • Introduction to SAR
      • Common formats for SAR commands
      • Analysis of common performance data of SAR
        • Overall CPU usage Statistics-u
        • Individual CPU usage Statistics-p
        • Memory usage Statistics-r
        • Overall IO situation-B
        • Each IO device condition-D
        • Network Statistics-N
        • SAR Log Save-O
      • References

Introduction to SAR

SAR (System activity Reporter): a great tool for monitoring the performance of Linux systems, including: Read and write files, usage of system calls, disk I/O, CPU efficiency, memory usage, Process activities and IPC-related activities.

Common formats for SAR commands

sar [ options ] [ <interval> [ <count> ] ]

which
Interval: Sampling period, unit is seconds;
Count: The number of samples, the default value is continuous sampling;
Options: command-line option.

There are many options for the SAR command, and only the common options are listed below:
-A: Sum of all reports
-U: Output statistics for overall CPU usage
-V: Output statistics for inode, files, and other kernel tables
-D: Output activity information for each block device
-r: Output memory and swap space statistics
-B: Display statistics for I/O and transfer rates
-A: File read and write status
-C: Output process statistics, number of processes created per second
-r: Output memory page statistics
-Y: terminal equipment activity situation
-W: Output system Exchange activity information

Analysis of common performance data of SAR

The following is a description of how to use SAR to obtain these profiling data:
-Overall CPU usage statistics
-Individual CPU usage statistics
-Memory usage statistics
-Overall I/O situation
-Conditions of each I/O device
-Network statistics

Overall CPU usage statistics (-u)

With the-u option, the SAR outputs the overall CPU usage, and the-u option is used by default when no option is added. The following command shows the sampling time is 3s, the number of samples is 2 times, the overall CPU usage:
SAR 3 2 (or Sar-u 3 2)

[Root@HB05-uhost-120L157 TMP]# SAR 3 2Linux2.6.32-279.19.31.el6.ucloud.x86_64 (hb05-uhost-130-157)01/17/_x86_64_ (CPU)11:58:PM CPU%user%nice%system%iowait%steal%idle11:58:5:00pm All13.250.003.163.720.0079.8711:58:$ PM All12.690.003.044.770.0079.50average:all12.970.003.104.250.0079.69[root@HB05-uhost-130-157 TMP]# sar-u 3 2Linux2.6.32-279.19.31.el6.ucloud.x86_64 (hb05-uhost-130-157)01/17/_x86_64_ (CPU)11:59:PM CPU%user%nice%system%iowait%steal%idle11:59:PM All22.24 0. XX 3.60 8.14 0. XX 66.0211:59:08 PM all 21.26 0. XX 4.28 6.95 0. XX 67.51average:all 21.75 0.00 3.94 7.55 0. 00 66.77          

14

Output Item Description:
Cpu:all represents the average of the statistics for all CPUs.
%usr:cpu the percentage of time in the user-state execution process.
%nice:cpu the percentage of total CPU time that is used in the nice operation in user-state mode.
The percentage of time the%SYSTEM:CPU is in the kernel-state execution process.
The percentage of%iowait:cpu used to wait for I/O operations to occupy the total CPU time.
%steal: The percentage of the hypervisor (hypervisor) that waits for a virtual CPU to serve another virtual process.
%IDLE:CPU idle time percentage.
1. If the%iowait value is too high, it indicates that the hard disk has an I/O bottleneck
2. If the value of the%idle is high but the system responds slowly, it is possible that the CPU waits for the allocated memory, at which time the memory capacity should be increased
3. If the value of%idle is consistently below 1, the system's CPU processing power is relatively low, indicating that the most needed solution in the system is the CPU

Individual CPU Usage statistics (-p)

The "-P all" option indicates the output statistics for each core:

Where the "CPU" column output 0,1,2,3,4,5 indicates the corresponding CPU core. It can also be displayed for a single core, and "-P 1" indicates the statistics for the second core.

Memory usage statistics (-R)

Use the-r option to display memory statistics, and the following command displays 2 memory information with 1 seconds of sample time:
Sar-r 1 2

parameter Parameters meaning
Kbmemfree Amount of free memory available in kilobytes.
Kbmemused Amount of used memory in kilobytes. This does don't take into account memory used by the kernel itself.
%memused Percentage of used Memory
Kbbuffers Amount of memory used as buffers by the kernel in kilobytes.
Kbcached Amount of memory used to cache data by the kernel in kilobytes.
Kbcommit Amount of memory in kilobytes needed for the current workload. This is a estimate of how much ram/swap are needed to guarantee that there never are out of memory.
%commit Percentage of memory needed for current workload in relation to the total amount of memory (RAM+SWAP). This number is greater than 100% because the kernel usually overcommits memory.
Overall I/O condition (-B)

Use the-B option to display disk I/O usage: report I/O and transfer rate statistics.
Sar-b 3 2

Output Item Description:
TPS: The number of requests per second for data to disk devices, including read and write requests, for Rtps and Wtps. For efficiency reasons, instead of processing the request immediately after the IO is issued, the request is merged (merge), where TPs refers to the request count after the request is merged.
Rtps: Number of Read requests to disk devices per second
Wtps: Number of write requests to disk devices per second
BREAD/S: The amount of data read from the physical device per second, in blocks/s
BWRTN/S: The amount of data written to the physical device per second, in blocks/s

Individual I/O device conditions (-D)

Use the-D option to display statistics for individual disks, and then increase the-p option to display the device name as SDX:
Sar-d-P 3 2

Output Item Description:
RD_SEC/S: Number of sectors read from the device per second
WR_SEC/S: Number of sectors written to the device per second
Avgrq-sz: The average size (in sectors) of the request sent to the device
Avgqu-sz: The average length of the request queue sent to the device
Await: The average time the service waits for an I/O request, including the request queue wait time (in milliseconds)
SVCTM: Average time the device handles I/O requests, excluding request queue wait time (in milliseconds)
%util: How much time in a second is spent on I/O operations, which is the percentage of CPU consumed by IO.

Note:
-If the%util is close to 100%, indicating that there are too many I/O requests and that the I/O system is full, the disk may have bottlenecks.
-If the SVCTM is closer to await, stating that I/O has almost no waiting time, and if the await is much larger than SVCTM, indicating that the I/O queue is too long and the IO response is too slow, the necessary optimizations are required.
-If the avgqu-sz is larger, it also indicates that there is an equivalent IO waiting.

Network statistics (-N)

Use the-N option to display network usage,-n followed by the keyword "DEV" to display eth0, eth1 and other network card information:
Sar-n DEV 1 1

The above main output meanings are as follows:
Iface:name of the network interface for which statistics is reported.
RXPCK/S: Total number of packets received per second.
TXPCK/S: Total number of packets transmitted per second.
RXKB/S: Total number of kilobytes (KB) received per second.
TXKB/S: Total number of kilobytes (KB) transmitted per second.
RXCMP/S: Number of compressed packets received per second (for Cslip etc).
TXCMP/S: Number of compressed packets transmitted per second.
RXMCST/S: Number of multicast packets received per second.

SAR log Save (-O)

Finally, how to save the SAR log, using the-o option, we can save the SAR statistics to a specified file, for the saved log, we can use the-f option to read:

linux:~ # sar-n DEV 1 10-o sar.out
linux:~ # sar-d 1 10-f sar.out
You can save more system resource information by using the-o option than redirecting the results to a file.

References:

1 http://www.thegeekstuff.com/2011/03/sar-examples/
2 http://www.cnblogs.com/bangerlee/articles/2545747.html
3 http://www.cnblogs.com/xianghang123/archive/2011/08/25/2153591.html
4 http://www.chinaz.com/server/2013/0401/297942.shtml

Linux uses SAR for performance analysis

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.