Use of the latest common performance analysis tools in Centos

Source: Internet
Author: User

In the previous article, I briefly introduced several aspects that affect linux performance and how to solve these problems, but how can we find problems in some or some aspects of the system? This requires several common performance analysis tools provided by linux, the following describes how to use these common performance analysis tools.

1. vmstat command
Vmstat is short for Virtual Meomory Statistics (Virtual Memory Statistics). This command tool is installed by default in many linux releases, the vmstat command can be used to monitor the memory information, Process status, and CPU activity of the operating system. The disadvantage is that a process cannot be deeply analyzed.
The vmstat syntax is as follows:
Vmstat [-V] [-n] [delay [count]
The options and parameters are described as follows:
L-V: Indicates printing and publishing information. It is an optional parameter.
L-n: indicates that the output header information is only displayed once during cyclic output.
L delay: the interval between two outputs.
L count: The number of times of statistics based on the specified time interval of "delay. The default value is 1.
For example:
Vmstat 3
It indicates that the output information is updated every three seconds, and the output is cyclically output. Press ctrl + c to stop the output.
Vmstat 3 5
Indicates that the output information is updated every 3 seconds, and the output is stopped after 5 counts.

2. iostat command
Iostat is short for I/O statistics (input/output statistics). It is mainly used to monitor system disk I/O operations. Its output mainly displays the statistics of disk read/write operations and CPU usage. Like vmstat, iostat cannot perform in-depth analysis on a process, but only analyzes the overall situation of the system.
Iostat is generally not installed with the system, to use iostat tool, you need to install a Sysstat toolkit on the system, Sysstat is an open source software, the official address for the http://pagesperso-orange.fr/sebastien.godard
You can select the source code package or rpm package for installation. The installation process is not described here. After the installation is complete, the system will have three additional commands: iostat, sar, and mpstat. Then you can run the iostat command directly in the system.
The iostat syntax is as follows:
Iostat [-c |-d] [-k] [-t] [-x [device] [interval [count]
The options and parameters are described as follows:
-C: displays the CPU usage.
-D: displays the disk usage.
-K: data is displayed in the unit of k bytes per second.
-T: the time when the statistics start to be executed.
-X device: specify the name of the disk device to be counted. The default value is all disk devices.
Interval: specifies the time interval between two statistics;
Count: The number of times specified by interval.

3. sar command
Sar commands are powerful and an important tool for analyzing system performance. Using sar commands, you can fully obtain the CPU, running queue, disk I/O, and paging (SWAP zone) of the system), memory, CPU interruption, network, and other performance data.
Sar format:
Sar [options] [g1] [-o filename] [interval [count]
The options and parameters are described as follows:
L options is the command line option, and there are many options for sar commands. below, only common options are listed:
-A: displays the running status of all resource devices (CPU, memory, and disks) in the system.
Ø-u: displays the Load Status of all CPUs in the system during the sampling time.
-P: displays the CPU usage specified in the current system.
-D: displays the usage of all hard disk devices in the system during the sampling time.
-R: displays the usage status of the system during the sampling time.
-B: displays the usage of the buffer during the sampling time.
-V: displays the status of processes, files, I nodes, and lock tables.
-N: displays the network running status. The parameters can be followed by DEV, EDEV, SOCK, and FULL. DEV displays network interface information, EDEV displays network error statistics, SOCK displays socket information, and FULL displays all three information. They can be used independently or together.
-Q: displays the size of the running queue, which is the same as the average load of the system at that time.
-R: displays the activity of the process during the sampling time.
-Y: displays the activity of the terminal device during the sampling time.
-W: displays the status of the system switching activity during the sampling time.
L-o filename: stores the command results in binary format, and filename is the file name.
L interval: indicates the sampling interval, which is a required parameter.
L count: indicates the number of samples. It is an optional parameter. The default value is 1.

For example:
You can use the following combination to view the overall load of the system CPU every 3 seconds and 5 times:
Sar-u 3 5
The system's CPU count starts from 0. To view the Running Load of the second CPU, use the following combination:
Sar-P 1 3 5
To view the read/write performance of the system disk, use the following combination:
Sar-d 3 5
Similarly, you can run the following command to view the system memory usage and network running status:
Sar-r 5 2
Sar-n DEV 5 3


4. system performance analysis standards


The main purpose of performance tuning is to enable the system to effectively use various resources and maximize the performance convergence between applications and systems, so that applications can run efficiently and stably. However, there is no strict definition of the standard for measuring the utilization rate of system resources, and there is no uniform saying for different systems and applications. Therefore, the standard provided here is actually an experience, table 15.1 provides general criteria for determining the utilization of system resources:
Table 1 provides general criteria for determining the utilization of system resources:


Table 1

Where:
% User: the percentage of time when the CPU is in user mode.
% Sys: the percentage of time when the CPU is in system mode.
% Iowait: Percentage of CPU waiting for input/output completion time.
Swap in: si, indicating page import of virtual memory, that is, switch from swap disk to RAM.
Swap out: so indicates page export of the virtual memory, that is, switching from RAM to swap disk.

5. At the end
We have explained three common system performance analysis tools. In fact, there are many other performance analysis tools in linux. For example, uptime can check the average CPU load and free can check the system memory usage, ps and top can be used together with the system to monitor the running status of processes, netstat can monitor network traffic conditions, and so on. The usage of these commands has been described many times in my previous articles, so I will not explain them here.

System performance optimization is a wide-ranging, tedious, and long-term task. It is often the most difficult part to find the root cause of a performance problem. Once you find the cause of the problem, the performance problem will be solved. Therefore, the idea of solving the problem becomes very important.

For example, in a website system in linux, users report that website access is slow and sometimes inaccessible.
To solve this problem, the first step is to check the network. You can run the ping command to check whether the domain name resolution of the website is normal and whether the delay of the ping SERVER address is too large. In this way, first, eliminate possible network problems. If there is no network problem, go to step 2 and check the memory usage of the linux system because the website responds slowly, generally, it is highly correlated with memory. Use commands such as free and vmstat to determine whether memory resources are in short supply. If there is no problem with memory resources, go to step 3 and check the system CPU load, the output of the sar, vmstat, top, and other commands can be used to determine whether the CPU is overloaded. If the CPU is normal, proceed to step 4 and check whether the system disk I/O has a bottleneck, you can use commands such as iostat and vmstat to check the disk's read/write performance. If there is no problem with disk read/write, the linux system's own performance issues are basically ruled out. The last thing to do is to check whether the program itself is faulty. With this approach, we can perform layer-by-layer detection and step-by-step troubleshooting to find out performance problems.

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.