What is the command to check Linux performance

08-01-2023

This article mainly introduces what are the commands to check Linux performance. In daily operations, I believe that many people have doubts about what is the command to check Linux performance. I hope it will help you to answer your doubts about the command to check the performance of Linux! Next, please follow the editor to learn together!

1.uptime

This command can quickly check the load of the machine. In the Linux system, these data represent the number of processes waiting for CPU resources and blocked in uninterruptible IO processes (process status is D). These data can give us a macroscopic understanding of system resource usage.

The output of the command represents the average load of 1 minute, 5 minutes, and 15 minutes respectively. Through these three data, you can understand whether the server load is tending to be tense or the area is easing. If the 1-minute average load is high, but the 15-minute average load is low, it means that the server is commanding a high load, and you need to further check where the CPU resources are consumed. Conversely, if the 15-minute average load is high and the 1-minute average load is low, it is possible that the moment when the CPU resources are tight has passed. If the average load in the last 1 minute is much higher than the load in 15 minutes, then we need to use the vmstat and mpstat commands to check.

2.dmesg|tail

dmesg This command is used to view the boot information

dmesg|tail This command will output the system The last 10 lines of the log

3.vmstat1

Each line will output some system core indicators, which allow us to understand the system status in more detail. The following parameter 2 indicates that the statistical information is output every two seconds. The header of the table indicates the meaning of each column. Here are some columns related to performance tuning:

r: Waiting for CPU resources number of processes. This data can better reflect the CPU load than the average load, and the data does not include processes waiting for IO. If this value is greater than the number of CPU cores of the machine, the CPU resources of the machine are saturated.

free: The amount of available memory in the system (in kilobytes). If the remaining memory is insufficient, it will also cause system performance problems. The free command introduced below can provide a more detailed understanding of the usage of system memory.

si,so: The number of writes and reads in the swap area. If this data is not 0, it means that the system is already using the swap area (swap), and the physical memory of the machine is insufficient.

us, sy, id, wa, st: These all represent the consumption of CPU time, which respectively represent user time (user), system (kernel) time (sys), idle time (idle), IO waiting time (wait) and stolen time (stolen, generally consumed by other virtual machines).

The above CPU time can let us quickly understand whether the CPU is busy. Generally, if the sum of user time and system time is very large, the CPU is busy executing instructions. If the IO wait time is very long, then the bottleneck of the system may be disk IO.

4.mpstat-PALL1

This command can display the usage of each CPU. If there is a CPU usage that is particularly high, it may be caused by a single-threaded application.

5.pidstat1

The pidstat command outputs the CPU usage of the process. This command will continue to output and will not overwrite the previous data, which is convenient for observation system dynamics.

6.iostat-xz1

The iostat command is mainly used to check the IO status of the machine disk. The main meanings of the columns output by this command are:

r/s, w/s, rkB/s, wkB/s: respectively indicate the number of reads and writes per second and the amount of read and write data per second (thousand words Festival). Excessive reading and writing may cause performance problems.

await: The average waiting time of IO operations, in milliseconds. This is the time that the application needs to consume when interacting with the disk, including the time spent on IO waiting and actual operation. If this value is too large, it may be that the hardware device has encountered a bottleneck or malfunctioned.

avgqu-sz: The average number of requests made to the device. If this value is greater than 1, the hardware device may be saturated (some front-end hardware devices support parallel writing).

%util: Equipment utilization. This value indicates how busy the device is. The empirical value is that if it exceeds 60, IO performance may be affected (you can refer to the average waiting time of IO operations). If it reaches 100%, it means that the hardware device is saturated.

If the data of the logical device is displayed, the device utilization does not mean that the actual hardware device at the back end is saturated. It is worth noting that even if the IO performance is not ideal, it does not necessarily mean that the application performance will be poor. Strategies such as pre-reading and write caching can be used to improve application performance.

7.free-h

free command can be used to view the usage of system memory, the last two columns respectively represent the number of memory used for IO cache, and the amount of memory used for the file system page cache. It should be noted that the second line -/+buffers/cache, it seems that the cache takes up a lot of memory space. This is the memory usage policy of the Linux system. Use the memory as much as possible. If the application needs memory, this part of the memory will be reclaimed and allocated to the application immediately.program. Therefore, this part of memory is generally also regarded as available memory.

If there is very little available memory, the system may use the swap area (if configured), which will increase IO overhead (can be withdrawn in the iostat command) and reduce system performance.

8.sar-nDEV1

The sar command can check the throughput rate of the network device here. When troubleshooting performance problems, you can use the throughput of the network device to determine whether the network device is saturated. As shown in the sample output, the throughput rate of the eth0 network card device is only about 0.39Mbytes/s.

9.sar-nTCP,ETCP1

The sar command is in This is used to view the TCP connection status, including:

active/s: the number of TCP connections initiated locally per second, which is the TCP connection created by the connect call;

passive/s : The number of TCP connections initiated remotely per second, that is, the TCP connection created by the accept call;

retrans/s: The number of TCP retransmissions per second;

The number of TCP connections can be used Determine whether the performance problem is due to the establishment of too many connections, and further determine whether the connection is actively initiated or passively accepted. TCP retransmission may be due to poor network environment or excessive server pressure, resulting in packet loss.

10.top

The first line is the task queue information, which is the same as the execution result of the uptime command: the first column indicates the current time, the second column Indicates how long the system has been running, the third column indicates the current number of logins, and the last loadaverage indicates the system load (the three values ​​are: 1 minute, 5 minutes, and 15 minutes ago to the present load average)

< p > The second column represents the information of the process, which is very intuitive.

At this point, the learning about the command to check Linux performance is over, and I hope to solve your doubts. The combination of theory and practice can better help you learn, go try it! If you want to continue to learn more relevant knowledge, please continue to pay attention to the Yisuyun website, and the editor will continue to work hard to bring you more practical articles!

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us