Linux下查看所有CPU核心使用率的方法

一:top命令
执行top命令后按数字1,就显示所有CPU核心使用率,但是当CPU核心数太多的时候,这个方法无法显示

  1. top - 14:13:07 up 2:59, 1 user, load average: 0.00, 0.04, 0.01
  2. Tasks: 133 total, 1 running, 132 sleeping, 0 stopped, 0 zombie
  3. 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
  4. 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
  5. Mem: 1024984k total, 1001912k used, 23072k free, 45484k buffers
  6. Swap: 1052248k total, 0k used, 1052248k free, 749124k cached
  7. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  8. 506 Oracle 16 0 1411m 17m 16m S 2.1 1.8 0:00.10 oracle
  9. 4833 root 15 0 90148 3396 2636 S 2.1 0.3 0:00.39 sshd
  10. 1 root 15 0 10368 680 572 S 0.0 0.1 0:00.59 init
  11. 2 root RT -5 0 0 0 S 0.0 0.0 0:03.71 migration/0
  12. 3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
  13. 4 root RT -5 0 0 0 S 0.0 0.0 0:03.71 migration/1
  14. 5 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
  15. 6 root 10 -5 0 0 0 S 0.0 0.0 0:04.48 events/0
  16. 7 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/1
  17. 8 root 10 -5 0 0 0 S 0.0 0.0 0:00.03 khelper
  18. 17 root 10 -5 0 0 0 S 0.0 0.0 0:00.01 kthread
  19. 22 root 10 -5 0 0 0 S 0.0 0.0 0:00.03 kblockd/0
  20. 23 root 10 -5 0 0 0 S 0.0 0.0 0:00.04 kblockd/1
  21. 24 root 14 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid
  22. 195 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/0
  23. 196 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/1
  24. 199 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khubd
  25. 201 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kseriod

二:sar命令
我一般都是用这个命令查看所有CPU核心使用率的,因为我的服务器核心数有48个,top命令无法显示。

  1. [root@server2 ~]# sar -P ALL 1 10
  2. Linux 2.6.18-274.el5 (server2.lanv.com) 07/06/2012
  3. 02:14:11 PM CPU %user %nice %system %iowait %steal %idle
  4. 02:14:12 PM all 0.00 0.00 0.00 0.00 0.00 100.00
  5. 02:14:12 PM 0 0.00 0.00 0.00 0.00 0.00 100.00
  6. 02:14:12 PM 1 0.00 0.00 0.00 0.00 0.00 100.00
  7. 02:14:12 PM CPU %user %nice %system %iowait %steal %idle
  8. 02:14:13 PM all 0.00 0.00 0.00 0.00 0.00 100.00
  9. 02:14:13 PM 0 0.00 0.00 0.00 0.00 0.00 100.00
  10. 02:14:13 PM 1 0.99 0.00 0.00 0.00 0.00 99.01
  11. 02:14:13 PM CPU %user %nice %system %iowait %steal %idle
  12. 02:14:14 PM all 0.00 0.00 0.00 0.00 0.00 100.00
  13. 02:14:14 PM 0 0.00 0.00 0.00 0.00 0.00 100.00
  14. 02:14:14 PM 1 0.00 0.00 0.00 0.00 0.00 100.00

相关推荐