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
Sar-u 1 5
By default, the cpu usage and other information displayed are sar-u;
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;
Sar-r
After-r is specified, you can view the memory usage in the room;
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;
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
Posted by: Large CC | 28DEC, 2013
Blog: blog.me115.com
Weibo: Sina Weibo