The method of using command to find the bottleneck of SAR in Linux

Source: Internet
Author: User
Tags memory usage cpu usage disk usage

Content Catalog

Back to the past statistics
View CPU Usage
View Average Load
View Memory usage
View Page Exchange occurrences
Installation
Description of SAR parameters


SAR to find the bottleneck of the system


SAR is the abbreviation for the system activity Reporter (Systems Activities report). The SAR tool will sample the current state of the system and then express the current state of the system by calculating the data and proportions. It is characterized by the continuous sampling of the system to obtain a large number of sampling data, sampling data and analysis results can be stored in the file, the required load is very small. SAR is one of the most comprehensive system performance analysis tools on Linux at present. The system's activities can be reported in 14 major areas, including the file read and write, system call usage, serial, CPU efficiency, memory usage, process activity and IPC-related activities, and are also more complex to use.

SAR is the most common and convenient tool for viewing operating system reporting metrics, and it has two uses;
1. Retrospective statistical data (default)
2. Periodic view of current data

To determine system bottleneck problems, sometimes several SAR command options are combined
Suspected CPU bottlenecks, available sar-u and sar-q, etc. to view
Suspected memory bottlenecks can be viewed with sar-b, Sar-r, and Sar-w.
Suspected I/O bottlenecks, available sar-b, sar-u, and sar-d to view

Back to the past statistics
By default, SAR displays data from the most recent 0:0, and if you want to continue to view a report a day ago, you can view the SA log saved under/var/log/sysstat/;
Use the SAR tool to view:
Sar-f/var/log/sysstat/sa28 | Head
Sar-r-f/var/log/sysstat/sa28

View CPU Usage
Sar-u 1 5
By default, information such as CPU usage is sar-u;

You can see this machine using virtualization technology, there is a corresponding time consumption;
The indicators for each column are:
%user
The proportion of CPU time consumed in user mode;
%nice
The process of scheduling priority by NICE changes the proportion of CPU time consumed in user mode
%system
The proportion of CPU time consumed in system mode;
%iowait
The proportion of time the CPU waits for disk I/O to cause idle state consumption;
%steal
With Xen and other operating system virtualization technology, waiting for other virtual CPU to calculate the proportion of time occupied;
%idle
CPU idle time ratio;

View Average Load
Sar-q
After you specify-Q, you can view the number of processes in the running queue, the process size on the system, the average load, and so on, and it can see how the indicators change over time compared to other commands;



Runq-sz: Length of Run queue (number of processes waiting to run)
Plist-sz: Number of processes (processes) and threads (threads) in the process list
Ldavg-1: System average load for last 1 minutes
LDAVG-5: Average system load of the last 5 minutes
LDAVG-15: Average system load of the last 15 minutes

View Memory usage
Sar-r
After specifying-R, you can view the memory usage in the house;



Kbmemfree: This value is basically the same as the free value in the null command, so it does not include buffer and cache space.
Kbmemused: This value is basically consistent with the used value in the free command, so it includes buffer and cache space.
%memused: Physical memory usage, which is a percentage of kbmemused and total memory (excluding swap).
Kbbuffers and kbcached: These two values are the buffer and cache in the free command.
Kbcommit: The memory needed to ensure that the current system is needed, that is, the memory (RAM+SWAP) required to make sure it does not overflow.
%commit: This value is a percentage of kbcommit and total memory, including swap.

View Page Exchange occurrences
sar-w
When a page is exchanged, the throughput of the server drops significantly, and if the server is in a bad condition, it is possible to use this command to confirm that a large number of exchanges have occurred if the page exchange occurs due to insufficient memory.



PSWPIN/S: Number of swap pages (Swap page) exchanged in system per second
PSWPOUT/S: Number of swap pages (Swap page) swapped out per second

Installation


Some Linux systems, the default may not install this package, using Apt-get install Sysstat to install;
After installation, turn on the Performance Collection Tool switch:
Vi/etc/default/sysstat
Enabled= "true"
Start this tool to collect system performance data:
/etc/init.d/sysstat start

Description of SAR parameters

Option features
-A Summary of all reports
-A report file read and write usage
-B report Additional cache usage
-B report Cache usage
-C reporting System call usage
-D reporting disk usage
-G Report Serial port Usage
-H Reporting statistics on buffer usage
-M reporting IPC Message Queuing and semaphore usage
-N reporting usage of named Cache
-P report Paging activity usage
-Q Report the average length of run queues and swap queues
-R reporting process activity
-R reports unused memory pages and hard disk blocks
-u reporting CPU Utilization
-V reporting process, I node, file and lock table status
-W Reporting System exchange activity
- Y reports TTY device activity status

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.