Home > Operation and Maintenance > Linux Operation and Maintenance > What command is used to check the Linux load?

What command is used to check the Linux load?

coldplay.xixi
Release: 2020-06-30 17:05:47
Original
3920 people have browsed it

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.

What command is used to check the Linux load?

The command to view the linux load is:

1. The top command to view the linux load:

What command is used to check 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
Copy after login
  • 11:03:08: System current time

  • up 1 days, 04:01: Elapsed time since system boot 1 day

  • ##3 users: Currently 3 users are online

  • load average:0.05, 0.05, 0.01: system 1 minute, 5 minutes, 15 Minute CPU load information.

Note: The three values ​​​​after load average mean the system load values ​​​​in the last minute, the last 5 minutes, and the last 15 minutes. The meaning of this value is the number of CPU active processes per unit time period. If your machine has a single core, then as long as these values ​​are all < 1, it means that there is no load pressure on the system. If your machine has N cores, then these values ​​must be < N to consider the system as having no load. pressure.

Explanation of the second line:

Tasks: 176 total, 1 running, 175 sleeping, 0 stopped, 0 zombie
Copy after login

  • 176 total: There are currently 176 tasks

  • 1 running: 1 task is running

  • 175 sleeping: 175 processes are sleeping

  • 0 stopped: Number of stopped processes

  • 0 zombie: Number of zombie processes

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
Copy after login

  • 0.1%us: The percentage of CPU time occupied by user mode processes

  • 0.2%sy: The percentage of CPU time occupied by the kernel

  • 0.2%ni : The CPU time percentage of the user-mode process of the task with a negative renice value. Nice means priority

  • 99.4%id: Percentage of idle CPU time

  • 0.0%wa: Percentage of CPU time waiting for I/O

  • 0.0%hi: CPU hard interrupt time percentage

  • 0.0%si: CPU soft interrupt time percentage

Explanation of the fourth line:

KiB Mem : 3882172 total, 1079980 free, 1684652 used, 1117540 buff/cache
Copy after login

  • 3882172 k total: total physical memory

  • 1684652k used: Physical memory used

  • 1079980k free: free physical memory

  • 1117540k cached: memory used as cache

Explanation of the fifth line:

KiB Swap: 0 total, 0 free, 0 used. 1871412 avail Mem
Copy after login

  • 0k total: the total amount of swap space

  • ##0k used : Used swap space
  • 0k free: Free swap space
  • ##1871412k cached: Cached swap space
  • Last line:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
Copy after login
PID: Process ID
  • USER: Owner of the process
  • PR: Priority of the process
  • NI: nice value
  • VIRT: occupied virtual Memory
  • RES: Physical memory occupied
  • SHR: Shared memory used
  • S : Progress state S: Hibernate R Running Z zombie process N Nice value is negative
  • %CPU: Occupied CPU
  • %MEM: Occupied Memory
  • TIME: The cumulative value of the time occupied by the CPU
  • COMMAND: Start command
  • 2. Check the linux load at uptime:

What command is used to check the Linux load?

3. Check the linux load with w:

What command is used to check the Linux load?

The first line refers to the explanation of the top command

USER TTY  FROM  LOGIN@ IDLE JCPU PCPU WHAT

Explanation is as follows:

USER - Login user name
  • TTY - Terminal number assigned by the system after login
  • FROM—Remote host name, that is, where to log in from
  • LOGIN@—When to log in
  • ##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

  • 4. Check linux load with vmstat

What command is used to check the Linux load?

  • 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

  • ##cat /proc/cpuinfo

    : You can view it CPU information, several processors equal several CPUs;

  • #sar

    : 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;

  • free

    : View the total memory size of the current system and memory usage;

  • ps

    : View the process, ps aux or ps -elf, often used together with the pipe character, to view a process or its number;

  • netstat

    : 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;

  • tcpdump

    : 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template