Linux常用命令之vmstat

Linux常用命令之vmstat

                                      

 

1.vmstat
vmstat是Virtual Meomory Statistics(虚拟内存统计)的缩写,可用来纪录 processes, memory, paging, block IO, traps, 与 cpu activity
 
[root@raclinux1 ~]# vmstat --help
usage: vmstat [-V] [-n] [delay [count]]
              -V prints version.
              -n causes the headers not to be reprinted regularly.
              -a print inactive/active page stats.
               -d prints disk statistics
              -D prints disk table
              -p prints disk partition statistics
              -s prints vm table
              -m prints slabinfo
              -S unit size
              delay is the delay between updates in seconds.
              unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
              count is the number of updates.
 
其中红色部分是新选项,2.5.70及以上内核适用
 
2.举例:
[oracle@raclinux1 ~]$ vmstat 3
procs -----------------memory---------------swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache       si   so     bi    bo   in    cs us sy id wa
 0  0      0   1672  29032 108664    0    0    66    16 1012   259  2  7 87  3
 0  0      0   1672  29040 108664    0    0     0    11  930   199  1  4 95  0
 0  0      0   1676  29040 108664    0    0     0    39  949   202  1  3 96  0
 0  0      0   1680  29048 108664    0    0     0     4  937   199  1  3 96  0
 0  0      0   1680  29048 108664    0    0     0    25  932   198  1  4 95  0
 0  0      0   1680  29056 108664    0    0     0     4  944   206  1  3 96  0
 0  0      0   1680  29056 108664    0    0     0     0  932   198  1  3 96  0
 0  0      0   1680  29064 108664    0    0     0     4  935   196  1  3 96  0
 0  0      0   1680  29064 108664    0    0     0     0  941   198  1  3 96  0
 0  0      0   1680  29072 108664    0    0     0     4  949   202  1  2 96  0
 0  0      0   1680  29072 108664    0    0     0     0  938   196  1  3 96  0
 
其中:
   Procs
       r: The number of processes waiting for run time.在运行队列中等候运行
       b: The number of processes in uninterruptible sleep.被资源阻塞(I/0,页面调度,等等)

                                                                                
   Memory
       swpd: the amount of virtual memory used.
       free: the amount of idle memory.
       buff: the amount of memory used as buffers.
       cache: the amount of memory used as cache.
       inact: the amount of inactive memory. (-a option)
       active: the amount of active memory. (-a option)
                                                                               
   Swap
       si: Amount of memory swapped in from disk (/s).
       so: Amount of memory swapped to disk (/s).
 
   IO
       bi: Blocks received from a block device (blocks/s).
       bo: Blocks sent to a block device (blocks/s).
    System
       in: The number of interrupts per second, including the clock.
       cs: The number of context switches per second.
 
   CPU
       These are percentages of total CPU time.
       us: Time spent running non-kernel code. (user time, including nice time)
       sy: Time spent running kernel code. (system time)
       id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
       wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.
 
3.解读:
A.CPU问题:
下面几列需要被察看,以确定cpu是否有问题
Processes in the run queue (procs r)
User time (cpu us)
System time (cpu sy)
Idle time (cpu id)
 
问题情况:
1.) 如果processes in run queue (procs r)的数量远大于系统中cpu的数量,将会使系统便慢。
2.) 如果这个数量是cpu的4倍的话,说明系统正面临cpu能力短缺,这将使系统运行速度大幅度降低
3.) 如果cpu的idle时间经常为0的话,或者系统占用时间(cpu sy)是用户占用时间(cpu us)两辈的话,系统面临缺少cpu资源
解决方案 :
解决这些情况,涉及到调整应用程序,使其能更有效的使用cpu,同时增加cpu的能力或数量
 
B.内存问题:
主要查看页导入的数值(swap中的si),如果该值比较大就要考虑内存,大概方法如下:
1).最简单的,加大RAM  
2).改小SGA,使得对RAM需求减少  
3).减少RAM的需求(如:减少PGA)
 
 
4.新参数:
 1).vmstat -D 显示磁盘信息(只能一次性,delay参数无效)
[oracle@raclinux1 ~]$ vmstat -D
           25 disks
            6  partitions 
     17577  total reads
      4140   merged reads
  587320   read sectors
  248149   milli reading
     6889   writes
    13672  merged writes
  164444  written sectors
  167353  milli writing
           0  inprogress IO
        178 milli spent IO
 
2).vmstat -d 查看磁盘统计信息
 
 [oracle@raclinux1 ~]$ vmstat -d | grep -v ram
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
hdc       13     88     680     249      0      0       0       0      0      0
sda    17396   2644  580819  243635   6983  13749  165836  167797      0    178
sdb       46    657    1185    1808      0      0       0       0      0      0
sdc       53    420    1436    1667      6      4      56       7      0      1
sdd       24    132    1248     348      0      0       0       0      0      0
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
sde       36    135    1368     288      0      0       0       0      0      0
sdf        9     64     584     154      0      0       0       0      0      0
fd0        0      0       0       0      0      0       0       0      0      0
md0        0      0       0       0      0      0       0       0      0      0
 
3).vmstat -s (一次性,delay参数无效)
 
[oracle@raclinux1 ~]$ vmstat -s
       256044  total memory
       254428  used memory
       153584  active memory
        70960  inactive memory
         1616  free memory
        33976  buffer memory
       104140  swap cache
      1044184  total swap
            0  used swap
      1044184  free swap
        13214 non-nice user cpu ticks
         3759 nice user cpu ticks
        43122 system cpu ticks
       827934 idle cpu ticks
        14246 IO-wait cpu ticks
           98 IRQ cpu ticks
        27960 softirq cpu ticks
       293660 pages paged in
        83714 pages paged out
            0 pages swapped in
            0 pages swapped out
      9369649 interrupts
      2217323 CPU context switches
   1143195570 boot time
        29804 forks

监控命令vmstat的使用(AIX系统)

上一篇 / 下一篇  2009-03-02 16:07:39 / 个人分类:性能测试

-----------命令使用------------------------------

vmstat 3
每3秒采集一次数据

------------性能问题表现----------------------------

内存不足pi,po长期不等于0
cpu负载大id经常小于20,r经常大于4
IO性能不好b中的队列大于3

------------参数解释--------------------------------

kthr
r--在运行队列中等待的进程数
b--在等待io的进程数

memoy
avm--
free--空闲的内存(k表示)

page
re--回收的页面
pi--进入页面数(k表示)
po--出页面数(k表示)
fr--空余的页面数(k表示)
sr--通过时钟算法扫描的页面


faults 显示每秒的中断数
in--设备中断
sy--系统中断
cy--cpu交换

cpu
cs--用户进程使用的时间
sy--系统进程使用的时间
id--cpu空闲的时间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值