Common commands for Linux to view system loads

Source: Internet
Author: User
Tags current time switches cpu usage high cpu usage

Web servers often encounter problems with the Linux system load, so what are the commands for viewing the system load under Linux?
The main commands for viewing the load under Linux are as follows:
Top, Uptime,w,vmstat
1.top command to view Linux load:


The first line explains:


Top-15:13:34 up 252 days, 1:36, 1 user, load average:0.01, 0.01, 0.00
15:13:34: System Current time
Up 252 Day: The system is now 252 days after the boot
1 Users: current 1 users online
Load average:0.01, 0.01, 0.00: System 1 minutes, 5 minutes, 15 minutes of CPU load information.
Note: The three values after the load average are the last 1 minutes, the last 5 minutes, and the last 15 minutes of system load values. The significance of this value is the number of CPU activity processes in the unit time period. If your machine is a single core, so long as these values are <1, there is no load pressure on behalf of the system, if your machine is n kernel, then must be these values are The second line explains:


tasks:69 Total, 1 running, sleeping, 0 stopped, 0 zombie
Total: currently has 69 tasks
1 Running:1 a task is running
The sleeping:68 process is in a sleep state
0 stopped: Number of processes stopped


0 Zombie: The number of zombie processes


The third line explains:


Cpu (s): 0.0%us, 0.0%sy, 0.0%ni, 99.3%id, 0.7%wa, 0.0%hi, 0.0%si, 0.0%st
0.0%us: Percent of CPU time consumed by the user state process
0.0%sy: Percentage of CPU time consumed by the kernel
The percentage of CPU time for the user-state process of the task with a negative 0.0%ni:renice value. Nice is the priority meaning
99.3%id: Percent of idle CPU time
0.7%wa: Percent of CPU time waiting for I/O
0.0%hi:cpu percent hard Break time
0.0%SI:CPU Soft break Time percent
Line four:
mem:508504k Total, 498388k used, 10116k free, 38848k buffers
2054588k Total: Overall physical memory
498388k used: Use of physical memory
10116k Free: Idle physical memory
38848k buffers: Memory used for caching
Line five:
swap:2097144k Total, 72504k used, 2024640k free, 56300k cached
2097144K Total: Amount of swap space
72504K used: Swap space used
2024640k Free: Idle swap space
56300k cached: Cached swap space
Last line:
PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND
PID: Process ID
USER: The owner of the process
PR: Priority of the process
Ni:nice value
Virt: Virtual Memory consumed
RES: Physical Memory occupied
SHR: Shared memory used
S: Proceed to State S: Hibernate R run z Zombie process N nice value is negative
%CPU: CPU Occupied
%MEM: Memory footprint
Time+: The cumulative value of CPU time
Command: Start commands
2.uptime View Linux Load:
After Linux runs the uptime command:
15:52:59 up 252 days, 2:16, 1 user, load average:0.07, 0.02, 0.00


Refer to the first line of the top command for an explanation


3.W View Linux Load:
After Linux runs the W command:
15:54:54 up 252 days, 2:18, 1 user, Load average:0.01, 0.00, 0.00
USER TTY from login@ IDLE jcpu pcpu WHAT
Root pts/0 221.237.158.253 15:08 0.00s 0.01s 0.00s W
The first line refers to the first line of the top name.
The USER TTY from login@ IDLE jcpu pcpu What is explained as follows:
user-logged in User name
tty-system-assigned terminal number after login
from-remote host name, which is where to log in
login@-when to log in
idle-idle for a long time, indicating the user idle time. This is a timer, and once the user does anything, the timer is reset
The time taken by all processes jcpu-and the terminal (TTY) connection, which does not include past background job times, but includes the time that is currently occupied by the running background job
Pcpu-refers to the time taken by the current process (that is, the process displayed in the What item)
what-the command line that is currently running the process
4.vmstat View Linux Load
Linux vmstat Command Detailed:
procs-----------Memory-------------Swap-------io------System-------CPU------
R b swpd free buff cache si so bi bo in CS us sy ID WA St
0 0 72500 10484 37820 50204 0 0 1 15 1 0 0 0 99 0-0
R indicates the running queue (that is, how many processes are actually allocated to the CPU), and when this value exceeds the number of CPUs, a CPU bottleneck occurs. This also and top of the load is related to the general load more than 3 higher, more than 5 on the high, more than 10 is not normal, the state of the server is very dangerous. The top load is similar to the run queue per second. If the running queue is too large, which means your CPU is busy, it will generally cause high CPU usage.
b is blocking the process, this is not much to say, process blocking, we understand.
SWPD virtual memory has been used in size, if greater than 0, indicates that your machine physical memory is not enough, if not the reason for the program memory leak, then you should upgrade the memory or the memory of the task to migrate to other machines.
Free of the physical memory size, my machine memory total 8G, remaining 3415M.
Buff Linux/unix system is used to store, directory contains what content, permissions, etc. cache, I this machine probably occupy more than 300 m
Cache cache is directly used to memorize the files we open, to buffer the files, (here is the smart of Linux/unix, the free physical memory part of the cache for files and directories, is to improve the performance of program execution, when the program uses memory, buffer/ Cached will soon be used. )
Si per second the size of the virtual memory from disk, if this value is greater than 0, indicates that the physical memory is not enough or memory leaks, to find the memory process to solve the loss. My machine has plenty of memory and everything is fine.
So per second virtual memory is written to disk size, if this value is greater than 0, ditto.
The number of blocks received by the BI block device per second, where the block device refers to all the disks and other block devices on the system, and the default block size is 1024byte.
The number of blocks sent by the Bo block device per second, for example, when we read the file, Bo must be greater than 0. Bi and Bo are generally close to 0, or IO is too frequent and need to be adjusted.
The number of CPU interrupts per second, including time outages
CS the number of context switches per second, for example, we call the system function, we need to do context switching, thread switching, also process context switch, this value to the smaller the better, too big, to consider the number of threads or processes, such as in Apache and nginx such a Web server, We generally do performance testing will be thousands of concurrent or even tens of thousands of concurrent testing, the process of selecting a Web server can be a process or thread peak has been reduced, pressure, until the CS to a relatively small value, the process and the number of threads is more appropriate value. System call is also, each call system functions, our code will enter the kernel space, resulting in context switching, this is very resource-intensive, but also try to avoid frequent call system functions. Too many context switches means that most of your CPU waste in context switching, resulting in less CPU time to do serious things, the CPU is not fully utilized, is not desirable.
US user CPU time, I used to do encryption decryption very frequently on the server, you can see us close to the 100,r run queue reached 80 (the machine is doing stress testing, poor performance).
SY system CPU time, if too high, indicates a long system call time, such as IO operations frequently.
ID free CPU time, in general, ID + US + sy = 100, generally considered the ID is idle CPU usage, US is the user CPU utilization, SY is the system CPU utilization rate.
WT waits for IO CPU time.

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.