Linux系统CPU使用情况

linux下有几个命令可以从系统中提取出CPU或内存的使用情况,如top、uptime、free、vmstat等
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>top
top - 14:11:52 up 592 days, 19:43,  3 users,  load average: 0.56, 0.56, 0.42
Tasks: 146 total,   1 running, 145 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.3%us,  0.0%sy,  0.0%ni, 98.0%id,  0.8%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   8183648k total,  7330648k used,   853000k free,   138736k buffers
Swap:  8193108k total,  2225392k used,  5967716k free,  2748992k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
24404 prm       16   0 2537m 2.4g  16m S    4 30.4 456:14.98 flowscheduler
23810 oracle    16   0 1713m 273m 269m S    1  3.4  14:11.07 oracle
23872 oracle    16   0 1712m  23m  19m S    0  0.3   1:05.45 oracle
8874 prm       16   0  5596 1240  868 R    0  0.0   0:00.03 top
    1 root      16   0   780   68   40 S    0  0.0  28:30.43 init
    2 root      RT   0     0    0    0 S    0  0.0   0:36.57 migration/0
    3 root      34  19     0    0    0 S    0  0.0   0:00.04 ksoftirqd/0
    4 root      RT   0     0    0    0 S    0  0.0   0:16.46 migration/1
    5 root      34  19     0    0    0 S    0  0.0   0:00.10 ksoftirqd/1
    6 root      RT   0     0    0    0 S    0  0.0   0:30.67 migration/2
    7 root      34  19     0    0    0 S    0  0.0   0:04.63 ksoftirqd/2
    8 root      RT   0     0    0    0 S    0  0.0   0:37.11 migration/3
    9 root      34  19     0    0    0 S    0  0.0   0:00.10 ksoftirqd/3
   10 root      10  -5     0    0    0 S    0  0.0   0:00.06 events/0
   11 root      10  -5     0    0    0 S    0  0.0   0:00.00 events/1
   12 root      10  -5     0    0    0 S    0  0.0   0:00.25 events/2
   13 root      10  -5     0    0    0 S    0  0.0   0:00.77 events/3
   14 root      10  -5     0    0    0 S    0  0.0   0:00.00 khelper
   15 root      10  -5     0    0    0 S    0  0.0   0:00.02 kthread
   21 root      10  -5     0    0    0 S    0  0.0   0:00.98 kblockd/0
   22 root      10  -5     0    0    0 S    0  0.0   0:02.10 kblockd/1
   23 root      10  -5     0    0    0 S    0  0.0   0:18.15 kblockd/2
   24 root      10  -5     0    0    0 S    0  0.0   0:19.84 kblockd/3
   25 root      13  -5     0    0    0 S    0  0.0   0:00.00 kacpid
  194 root      15   0     0    0    0 S    0  0.0  31:28.04 kswapd0
  195 root      10  -5     0    0    0 S    0  0.0   0:00.00 aio/0
  196 root      11  -5     0    0    0 S    0  0.0   0:00.00 aio/1
  197 root      10  -5     0    0    0 S    0  0.0   0:00.00 aio/2
  198 root      11  -5     0    0    0 S    0  0.0   0:00.00 aio/3
  419 root      10  -5     0    0    0 S    0  0.0   0:00.00 cqueue/0
  420 root      10  -5     0    0    0 S    0  0.0   0:00.00 cqueue/1
  421 root      10  -5     0    0    0 S    0  0.0   0:00.00 cqueue/2
  422 root      11  -5     0    0    0 S    0  0.0   0:00.00 cqueue/3
  423 root      10  -5     0    0    0 S    0  0.0   0:00.00 kseriod
  454 root      10  -5     0    0    0 S    0  0.0   0:00.00 kpsmoused
  826 root      10  -5     0    0    0 S    0  0.0   0:00.00 ata/0
  827 root      10  -5     0    0    0 S    0  0.0   0:00.00 ata/1
  828 root      10  -5     0    0    0 S    0  0.0   0:00.00 ata/2
  829 root      11  -5     0    0    0 S    0  0.0   0:00.00 ata/3


======================================================================
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>free
             total       used       free     shared    buffers     cached
Mem:       8183648    7330384     853264          0     138736    2748992
-/+ buffers/cache:    4442656    3740992
Swap:      8193108    2225392    5967716
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>


======================================================================
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>uptime
  2:13pm  up 592 days 19:45,  3 users,  load average: 0.58, 0.56, 0.43
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>

2:13pm:系统当前时间
up 592 days 19:45 系统已经运行的时间
3 users:当前已经登录到系统的用户个数
load average: 0.58, 0.56, 0.43:1、5和15分钟的系统负载平均值

======================================================================
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>vmstat
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 2225392 851784 138736 2748992    0    0    11    38    0    0  5  0 93  2  0
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>


prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>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
0  0 2225392 845940 138740 2750016    0    0    11    38    0    0  5  0 93  2  0
1  0 2225392 845940 138740 2750016    0    0     0     0  262  468  7  0 93  0  0
0  0 2225392 845948 138740 2750016    0    0     0    48  265  448  7  0 93  0  0
0  0 2225392 845948 138740 2750016    0    0     0   564  313  481  2  0 97  1  0
0  0 2225392 842188 138740 2750016    0    0     0    32  335  771  3  2 90  6  0
prm@ATAE1-ESG-E4:/home/prm/mice/log/20111115>

r:      等待CPU时间的进程数
b:      不间断休眠中的进程数 
swpd:   使用的虚拟内存量(以MB为单位)
free:   未使用的物理内存量(以MB为单位)
buff:   用作缓存空间的内存量(以MB为单位)
cache:  用作高速缓存空间的内存量(以MB为单位)
si:     从磁盘交换的内存量(以MB为单位)
so:     交换到磁盘的内存量(以MB为单位)
bi:     从块设备收到的块数
bo:     发送到块设备的块数
in:     每秒CPU的中断数
cs:     每秒CPU的上下文交换数
us:     CPU消耗在运行非内核代码上的时间百分比
sy:     CPU消耗在运行内核代码上的时间百分比
id:     CPU空间的时间百分比
wa:     CPU消耗的在等待I/O上的时间百分比
st:     从虚拟机窃取的CPU时间百分比

猜你喜欢

转载自hulu26.iteye.com/blog/1262019