Home > Linux, 工具介绍, 调优 > disktop per设备per应用层面的IO读写统计

disktop per设备per应用层面的IO读写统计

May 16th, 2011

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: disktop per设备per应用层面的IO读写统计

我们在调优IO 密集型的应用是通常需要知道IO的使用情况. 但是iostat只能知道系统全局的,iotop只能知道每个应用的, 我们有时候需要细化到每个应用对每个设备的使用情况. 比如说mysql数据库我们通常把日志和数据分开到不同的设备, 那我们需要知道数据读写多少,日志读写多少,分开的了解.

目前还没有工具能够很轻松的了解. 幸运的是systemtap自己带的disktop可以帮我们做到,位于/usr/share/doc/systemtap/examples/io/disktop.stp.

我们先来配置下环境:

$ uname -r
2.6.18-164.el5
$ rpm -i kernel-debuginfo-common-2.6.18-164.el5.x86_64.rpm
$ rpm -i kernel-debuginfo-2.6.18-164.el5.x86_64.rpm  
$stap -V
Systemtap translator/driver (version 1.5 /0.137 commit release-1.4-144-gdce37b5 + changes)
Copyright (C) 2005-2011 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: AVAHI LIBRPM LIBSQLITE3 NSS BOOST_SHARED_PTR TR1_UNORDERED_MAP NLS

这样就好了.
我们接着看如何使用:

$mount
/dev/sda11 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda6 on /tmp type ext3 (rw)
/dev/sda5 on /home type ext3 (rw)
/dev/sda3 on /usr type ext3 (rw)
/dev/sda2 on /var type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sdb1 on /u01 type ext3 (rw,noatime,nodiratime,barrier=0)

$sudo stap /usr/share/doc/systemtap/examples/io/disktop.stp

Mon May 16 05:39:20 2011 , Average:4054Kb/sec, Read:    2219Kb, Write:  18051Kb

     UID      PID     PPID                       CMD   DEVICE    T        BYTES
     502     8914     8639                    mysqld     sdb1    W     18366678
     502     8914     8639                    mysqld    sda11    R      2020497
   50672    24711     9796                     mysql     sda5    W       117430
     502    24748    30385                     mysql    sda11    R        47895
     502    24752    30385                     mysql    sda11    R        47895
     502    24756    30385                     mysql    sda11    R        47895
     502    24760    30385                     mysql    sda11    R        47895
     502    24747    24745                      grep     sda3    R         4528
     502    24751    24749                      grep     sda3    R         4528
     502    24755    24753                      grep     sda3    R         4528

...

很简单的把,每5秒打印出使用IO最多的10个进程,有需要的话可以自己改下脚本.

祝玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

  1. 谢良
    May 17th, 2011 at 11:09 | #1

    mount最后一行/dev/sdb1的选项很上道,哈哈

  2. May 19th, 2011 at 19:25 | #2

    pidstat可以, 而且不用装debug-info 🙂

    Yu Feng Reply:

    pidstat无法做到per设备呀!

  3. June 15th, 2011 at 17:28 | #3

    stap /usr/share/doc/systemtap-0.7.2/examples/io/disktop.stp 报错:
    semantic error: libdwfl failure (missing kernel 2.6.18-128.el5 i686 debuginfo): No such file or directory while resolving probe point kernel.function(“vfs_read”).return
    semantic error: no match while resolving probe point kernel.function(“vfs_write”).return
    Pass 2: analysis failed. Try again with more ‘-v’ (verbose) options.

    咋回事?

    Yu Feng Reply:

    符号信息没安装,或者没安装好。。。

Comments are closed.