In Linux system maintenance, you may need to review CPU usage frequently and analyze the overall operation of the system. The performance of the monitoring CPU typically includes the following 3 points: Run queues, CPU usage, and context switching.
The best way to run a queue for each CPU is not to exceed 3, for example, if the dual-core CPU is not more than 6. If the queue stays above 3 for a long time, it means that no one process can get a CPU response immediately, and you may need to consider upgrading the CPU. In addition the full load running CPU usage is best is the user space to keep in 65%~70%,system space to keep in 30%, idle keep in 0%~5%.
Below is a summary of several commands commonly used to view CPU usage. 1, top
This command is very common, in the third line shows the current CPU usage.
[root@li676-235 ~]# top-bn 1-i-C
top-14:19:51 up 138, 7:15, 1 user, load average:0.20, 0.33, 0.39
Tasks : Total, 1 running, 114 sleeping, 0 stopped, 0 zombie
Cpu (s): 4.5%us, 3.8%sy, 0.0%ni, 91.0%id, 0.6%wa, 0.0%hi, 0.0 %si, 0.0%st
mem:1014660k Total, 880512k used, 134148k free, 264904k buffers
swap:262140k Total, 34788k used, 227 352k free, 217144k cached
PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND
12760 root 0 15084 1944 1632 R 2.0 0.2 0:00.01 top-bn 1-i-C
As shown above, the top command can see the overall system running state and CPU usage.
%us: Indicates the CPU usage of the User space program (not through the Nice Dispatch)
%sy: Represents the CPU usage of the system space, mainly the kernel program.
%ni: CPU Usage for programs that represent user space and pass through the nice tune.
%id: Idle CPU
%wa:cpu time to wait io at runtime
%HI:CPU handle the number of hard interrupts
Number of%si:cpu handling soft interrupts
%st: CPU stolen by Virtual machine 2, Vmstat
Previously in this blog has introduced the use of Vmstat, detailed use and parameter Introduction reference site: http://www.sijitao.net/1925.html.
[root@li676-235 ~]# vmstat 1 5
procs-----------memory-------------Swap-------io------System-------CPU-----
r b swpd free buff cache si so bi bo in CS us sy ID WA St
2 0 34792 68376 147688 356132 16 16 421 385 2 2 5 4 1 0
3 0 34792 97368 147688 326884 0 0 0 0 134 6 0 0 1 0 34792 62432 147696 360704 0 0 0 88 267 278 63
19 0 0