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?

Jun 30, 2020 am 11:40 AM
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.

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is Linux actually good for? What is Linux actually good for? Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Using Docker with Linux: A Comprehensive Guide Using Docker with Linux: A Comprehensive Guide Apr 12, 2025 am 12:07 AM

Using Docker on Linux can improve development and deployment efficiency. 1. Install Docker: Use scripts to install Docker on Ubuntu. 2. Verify the installation: Run sudodockerrunhello-world. 3. Basic usage: Create an Nginx container dockerrun-namemy-nginx-p8080:80-dnginx. 4. Advanced usage: Create a custom image, build and run using Dockerfile. 5. Optimization and Best Practices: Follow best practices for writing Dockerfiles using multi-stage builds and DockerCompose.

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

How to start apache How to start apache Apr 13, 2025 pm 01:06 PM

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

How to start monitoring of oracle How to start monitoring of oracle Apr 12, 2025 am 06:00 AM

The steps to start an Oracle listener are as follows: Check the listener status (using the lsnrctl status command) For Windows, start the "TNS Listener" service in Oracle Services Manager For Linux and Unix, use the lsnrctl start command to start the listener run the lsnrctl status command to verify that the listener is started

How to monitor Nginx SSL performance on Debian How to monitor Nginx SSL performance on Debian Apr 12, 2025 pm 10:18 PM

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

How to set up a recycling bin in Debian system How to set up a recycling bin in Debian system Apr 12, 2025 pm 10:51 PM

This article introduces two methods of configuring a recycling bin in a Debian system: a graphical interface and a command line. Method 1: Use the Nautilus graphical interface to open the file manager: Find and start the Nautilus file manager (usually called "File") in the desktop or application menu. Find the Recycle Bin: Look for the Recycle Bin folder in the left navigation bar. If it is not found, try clicking "Other Location" or "Computer" to search. Configure Recycle Bin properties: Right-click "Recycle Bin" and select "Properties". In the Properties window, you can adjust the following settings: Maximum Size: Limit the disk space available in the Recycle Bin. Retention time: Set the preservation before the file is automatically deleted in the recycling bin

How to optimize the performance of debian readdir How to optimize the performance of debian readdir Apr 13, 2025 am 08:48 AM

In Debian systems, readdir system calls are used to read directory contents. If its performance is not good, try the following optimization strategy: Simplify the number of directory files: Split large directories into multiple small directories as much as possible, reducing the number of items processed per readdir call. Enable directory content caching: build a cache mechanism, update the cache regularly or when directory content changes, and reduce frequent calls to readdir. Memory caches (such as Memcached or Redis) or local caches (such as files or databases) can be considered. Adopt efficient data structure: If you implement directory traversal by yourself, select more efficient data structures (such as hash tables instead of linear search) to store and access directory information

See all articles