Home >Operation and Maintenance >Linux Operation and Maintenance >What command is used to check the Linux load?
The commands to view the linux load are: 1. [top] command to view the linux load; 2. [uptime] command to view the linux load; 3. [w] command to view the linux load; 4. [vmstat] command to view linux load.
The command to view the linux load is:
1. The top command to view the linux load:
Related learning recommendations: linux video tutorial
Explanation of the first line:
top - 11:03:08 up 1 days, 04:01, 3 user, load average: 0.05, 0.05, 0.01
11:03:08: System current time
up 1 days, 04:01: Elapsed time since system boot 1 day
Explanation of the second line:
Tasks: 176 total, 1 running, 175 sleeping, 0 stopped, 0 zombie
Explanation of the third line:
%Cpu(s): 0.1 us, 0.2 sy, 0.2 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
Explanation of the fourth line:
KiB Mem : 3882172 total, 1079980 free, 1684652 used, 1117540 buff/cache
Explanation of the fifth line:
KiB Swap: 0 total, 0 free, 0 used. 1871412 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMANDPID: Process ID
3. Check the linux load with w:
The first line refers to the explanation of the top command
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
Explanation is as follows:##IDLE —How long has it been idle, indicating the time the user has been idle. This is a timer that will be reset once the user performs any operation.
JCPU—The time occupied by all processes connected to the terminal (tty). This time It does not include the past background job time, but includes the time taken by the currently running background job.
PCPU - refers to the current process (that is, the process displayed in the WHAT item) Time taken
WHAT—Command line of the currently running process
r
represents the running queue (that is, how many processes are actually assigned to CPU), when this value exceeds the number of CPUs, a CPU bottleneck will occur. This is also related to the load of top. Generally, if the load exceeds 3, it is relatively high, if it exceeds 5, it is high, if it exceeds 10, it is abnormal, and the status of the server is very dangerous. The load of top is similar to the run queue per second. If the run queue is too large, it means that your CPU is very busy, which generally results in high CPU usage.
#b
represents a blocked process. I won’t go into details about this, but everyone knows that the process is blocked.
swpd The used size of virtual memory. If it is greater than 0, it means that your machine’s physical memory is insufficient. If it is not the cause of program memory leak, then you should upgrade the memory or reduce the consumption. Memory tasks are migrated to other machines.
free
The size of free physical memory, my machine memory has a total of 8G, and the remaining 3415M.
buff Linux/Unix
The system is used to store, cache the content in the directory, permissions, etc. My machine takes up about 300 M
cache cache
is directly used to remember the files we open and buffer them. (This is the cleverness of Linux/Unix, taking part of the free physical memory. The purpose of caching files and directories is to improve the performance of program execution. When the program uses memory, buffer/cached will be used quickly.)
si
The size of the virtual memory read from the disk per second. If this value is greater than 0, it means that the physical memory is not enough or the memory is leaked. You need to find the memory-consuming process and solve it. My machine has plenty of memory and everything works fine.
so
The size of virtual memory written to disk per second. If this value is greater than 0, the same as above.
bi
The number of blocks received by the block device per second. The block device here refers to all disks and other block devices on the system. The default block size is 1024byte.
bo
The number of blocks sent by the block device per second. For example, when we read a file, bo must be greater than 0. Bi and bo are generally close to 0, otherwise the IO is too frequent and needs to be adjusted.
in
Number of CPU interrupts per second, including time interrupts
## cs The number of context switches per second. For example, when we call a system function, we need to perform context switching, thread switching, and process context switching. The smaller the value, the better. If it is too large, consider lowering the thread or The number of processes. For example, in web servers such as apache and nginx, when we do performance testing, we usually conduct thousands or even tens of thousands of concurrency tests. The processes selected for the web server can be adjusted downward according to the peak value of the process or thread. Stress testing , until cs reaches a relatively small value, the number of processes and threads is a more appropriate value. The same goes for system calls. Every time a system function is called, our code will enter the kernel space, causing context switching. This is very resource-consuming, and we should try to avoid calling system functions frequently. Excessive context switching means that most of your CPU is wasted on context switching, resulting in less time for the CPU to do serious work, and the CPU is not fully utilized, which is not advisable.
us User CPU time, I was once on a server that does encryption and decryption very frequently. I can see that us is close to 100, and the r run queue reaches 80 (machine Doing stress testing, performance is not good).
sy System CPU time, if it is too high, it means that the system call time is long, such as frequent IO operations.
id Idle CPU time, generally speaking, id us sy = 100, it is generally believed that id is the idle CPU usage, us is the user CPU usage, sy is the system CPU usage.
#wt Waiting for IO CPU time.
5. Some other operations
: You can view it CPU information, several processors equal several CPUs;
: You can monitor the status of all resources in the system, sar -n DEV to check the network card traffic history, sar - q Check the historical load. The most useful thing is to check the network card traffic. If the traffic is too large: If rxpck/s is greater than 4000, or rxKB/s is greater than 5000, it is likely to be attacked, and packet capture and analysis are required;
: View the total memory size of the current system and memory usage;
: View the process, ps aux or ps -elf, often used together with the pipe character, to view a process or its number;
: View the port, netstat -lnp is used Print which ports are currently enabled on the system. netstat -an is used to print network connection status;
: Packet capture tool analyzes data packets to know which IPs are there Attack; you can write the content into the specified file 1.cap, display the contents of the package, and display the data flow direction on the screen without adding -w;
wireshark
: Packet capture tool, you can temporarily use this command to view web requests on the current server
The above is the detailed content of What command is used to check the Linux load?. For more information, please follow other related articles on the PHP Chinese website!