一:top命令
执行top命令后按数字1,就显示所有CPU核心使用率,但是当CPU核心数太多的时候,这个方法无法显示
top - 14:13:07 up 2:59, 1 user, load average: 0.00, 0.04, 0.01
Tasks: 133 total, 1 running, 132 sleeping, 0 stopped, 0 zombie
Cpu0 : 0.1%us, 0.3%sy, 0.2%ni, 98.9%id, 0.5%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu1 : 0.1%us, 0.4%sy, 0.3%ni, 98.7%id, 0.6%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1024984k total, 1001912k used, 23072k free, 45484k buffers
Swap: 1052248k total, 0k used, 1052248k free, 749124k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
506
Oracle 16 0 1411m 17m 16m S 2.1 1.8 0:00.10 oracle
4833 root 15 0 90148 3396 2636 S 2.1 0.3 0:00.39 sshd
1 root 15 0 10368 680 572 S 0.0 0.1 0:00.59 init
2 root RT -5 0 0 0 S 0.0 0.0 0:03.71 migration/0
3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
4 root RT -5 0 0 0 S 0.0 0.0 0:03.71 migration/1
5 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
6 root 10 -5 0 0 0 S 0.0 0.0 0:04.48 events/0
7 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/1
8 root 10 -5 0 0 0 S 0.0 0.0 0:00.03 khelper
17 root 10 -5 0 0 0 S 0.0 0.0 0:00.01 kthread
22 root 10 -5 0 0 0 S 0.0 0.0 0:00.03 kblockd/0
23 root 10 -5 0 0 0 S 0.0 0.0 0:00.04 kblockd/1
24 root 14 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid
195 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/0
196 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/1
199 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khubd
201 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kseriod
二:sar命令
我一般都是用这个命令查看所有CPU核心使用率的,因为我的服务器核心数有48个,top命令无法显示。
[root@server2 ~]# sar -P ALL 1 10
Linux 2.6.18-274.el5 (server2.lanv.com) 07/06/2012
02:14:11 PM CPU %user %nice %system %iowait %steal %idle
02:14:12 PM all 0.00 0.00 0.00 0.00 0.00 100.00
02:14:12 PM 0 0.00 0.00 0.00 0.00 0.00 100.00
02:14:12 PM 1 0.00 0.00 0.00 0.00 0.00 100.00
02:14:12 PM CPU %user %nice %system %iowait %steal %idle
02:14:13 PM all 0.00 0.00 0.00 0.00 0.00 100.00
02:14:13 PM 0 0.00 0.00 0.00 0.00 0.00 100.00
02:14:13 PM 1 0.99 0.00 0.00 0.00 0.00 99.01
02:14:13 PM CPU %user %nice %system %iowait %steal %idle
02:14:14 PM all 0.00 0.00 0.00 0.00 0.00 100.00
02:14:14 PM 0 0.00 0.00 0.00 0.00 0.00 100.00
02:14:14 PM 1 0.00 0.00 0.00 0.00 0.00 100.00