In linux, sar uses commands to identify system bottlenecks

Source: Internet
Author: User

Sar (System Activity Reporter System Activity Report) is one of the most comprehensive System performance analysis tools on Linux. It can report System activities from multiple parties, including: file read/write status and other functions. The following describes how to use the linux sar command to find the system bottleneck.

Content directory

Trace past statistics
View CPU usage
View average load
View memory usage
View page Switch Status
Install
Sar parameter description


Sar's powerful tool for identifying system bottlenecks


Sar is short for System Activity Reporter. The sar tool samples the current status of the system and then calculates the data and proportions to express the current running status of the system. It is characterized by continuous sampling of the system to obtain a large amount of sampling data. The sampling data and analysis results can be stored in files, requiring little load. Sar is currently one of the most comprehensive system performance analysis tools in Linux. It can report system activities in 14 ways, including file read/write, system call usage, serial port, CPU efficiency, memory usage, process activity, and IPC-related activities.

Sar is the most common and convenient tool for viewing operating system report indicators. It has two usage methods;
1. Trace past statistics (default)
2. Periodically view the current data

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.

Trace past statistics
By default, sar displays data from the last 00:00. If you want to view the report one day ago, you can view the sa logs saved under/var/log/sysstat;
View using the sar tool:
Sar-f/var/log/sysstat/sa28 | head
Sar-r-f/var/log/sysstat/sa28

View CPU usage
Sar-u 1 5
By default, the cpu usage and other information displayed are sar-u;
 

We can see that this machine uses virtualization technology, which consumes time;
The indicators of each column are:
% User
The proportion of CPU time consumed in user mode;
% Nice
The proportion of CPU time consumed in user mode for processes whose scheduling priority is changed by nice
% System
The proportion of CPU time consumed in system mode;
% Iowait
Percentage of time consumed by idle state due to CPU wait for disk I/O;
% Steal
Wait for other virtual CPUs to calculate the time used by operating system virtualization technologies such as Xen;
% Idle
CPU idle time ratio;

View average load
Sar-q
After-q is specified, you can view the number of processes in the running queue, the size of processes in the system, and the average load. Compared with other commands, it can view the time-varying status of various indicators;


 
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
Ldavg-5: average system load for the past 5 minutes
Ldavg-15: average system load for the past 15 minutes

View memory usage
Sar-r
After-r is specified, you can view the memory usage in the room;


 
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: physical memory usage, which 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.

View page Switch Status
Sar-W
When page switching occurs, the server's throughput will be greatly reduced. If the server is in bad condition, if you suspect that the page switching is caused by insufficient memory, you can use this command to check whether a large number of exchanges have occurred;


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

Install


In some linux systems, this package may not be installed by default. You can use apt-get install sysstat to install it;
After installation, turn on the performance collection tool:
Vi/etc/default/sysstat
ENABLED = "true"
Start this tool to collect system performance data:
/Etc/init. d/sysstat start

Sar parameter description

Option
-A summarize all reports
-A: report file read/write usage
-B. Report the usage of the additional cache.
-B: Report Cache Usage
-C: Report System Call usage
-D. Report disk usage
-G: Report serial port usage
-H reports statistics on buffer usage
-M: report the use of IPC message queues and semaphores
-N: Report the usage of named cache
-P: Report page activity usage
-Average length of q report queue and switch queue
-R: Reporting Process Activity
-R reports unused memory pages and hard disk blocks
-U reports CPU utilization
-V Report process, I node, file, and lock Table Status
-W report system exchange activity status
-Y: Report TTY device activity status

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.