以下转自http://www.xaprb.com/blog/2009/08/23/how-to-find-per-process-io-statistics-on-linux/

Newer Linux kernels have per-process I/O accounting and you can use the iotop tool to find out what’s performing I/O, but in many cases I’m trying to find the source of an I/O problem in an older kernel. I found sort of a hack-ish way to do that today, while trying to figure out why a system was basically unresponsive.

I found a post on Stack Overflow that showed a way you can get per process I/O statistics from the kernel even in older kernels. I adapted this to my needs, and wrote a little script.

Here’s how you use it. First, get it:

wget http://aspersa.googlecode.com/svn/trunk/iodump

Then turn on kernel messages about I/O:

echo 1 > /proc/sys/vm/block_dump

This makes the kernel start writing messages about every I/O operation that takes place. Now all you have to do is get those messages and feed them into my script:

while true; do sleep 1; dmesg -c; done | perl iodump

Wait a little while, then cancel the script. The results should look something like the following:

root@kanga:~# while true; do sleep 1; dmesg -c; done | perl iodump
^C# Caught SIGINT.
TASK PID TOTAL READ WRITE DIRTY DEVICES
firefox 4450 4538 251 4287 0 sda4, sda3
kjournald 2100 551 0 551 0 sda4
firefox 28452 185 185 0 0 sda4
kjournald 782 59 0 59 0 sda3
pdflush 31 30 0 30 0 sda4, sda3
syslogd 2485 2 0 2 0 sda3
firefox 28414 2 2 0 0 sda4, sda3
firefox 28413 1 1 0 0 sda4
firefox 28410 1 1 0 0 sda4
firefox 28307 1 1 0 0 sda4
firefox 28451 1 1 0 0 sda4

I deliberately generated a bunch of I/O by deleting my Firefox history and cache.

Add by huangbt:)

#!/bin/sh
 
while :
do
#echo "1" > /proc/sys/vm/block_dump
exec 6>&1 1>/tmp/iomon.log
dmesg | egrep "READ|WRITE|dirtied" | awk '{print $1,$2,$3,$4,$NF}' | sort
exec 1>&6 6>&-
dmesg | egrep "READ|WRITE|dirtied" | awk '{print $1,$2,$NF}' | sort | uniq -c | sort -rn | head|awk 'BEGIN{print "COUNTS COMMAND(PID) I/O DEVICE"}{print}'|column -t
#echo "0" > /proc/sys/vm/block_dump
sleep 1
clear
done

How to find per-process I/O statistics on Linux的更多相关文章

  1. kkjcre1p: unable to spawn jobq slave process, slot 0, error 1089(Linux x86_64)补丁

    在shutdown immediately的时候,alert Log出现如下错误信息,并且不能正常关闭 kkjcre1p: unable to spawn jobq slave process, sl ...

  2. How to kill a process on a port on linux 怎么杀死 关掉一个端口

    sudo kill `sudo lsof -t -i:9001`

  3. The Linux Process Principle,NameSpace, PID、TID、PGID、PPID、SID、TID、TTY

    目录 . 引言 . Linux进程 . Linux命名空间 . Linux进程的相关标识 . 进程标识编程示例 . 进程标志在Linux内核中的存储和表现形式 . 后记 0. 引言 在进行Linux主 ...

  4. java Process的waitFor()

    java Process的waitFor() 在编写Java程序时,有时候我们需要调用其他的诸如exe,shell这样的程序或脚本.在Java中提供了两种方法来启动其他程序: (1) 使用Runtim ...

  5. EDKII Build Process:EDKII项目源码的配置、编译流程[三]

    <EDKII Build Process:EDKII项目源码的配置.编译流程[3]>博文目录: 3. EDKII Build Process(EDKII项目源码的配置.编译流程) -> ...

  6. process credentials(一)

    一.介绍 当linux系统中的一个进程运行起来的时候,总是要访问系统的资源,访问文件或者向其他的进程发送信号.系统是否允许其进行这些操作?系统是根据什么来判断该进程的权限?这些问题是和进程信任状(pr ...

  7. [中英对照]Booting Process in Linux RHEL 7 | Linux RHEL 7启动过程

    Booting Process in Linux RHEL 7 | Linux RHEL 7启动过程 In this post, I will guide you booting process in ...

  8. 最大化 AIX 上的 Java 性能,第 4 部分: 监视流量

    http://www.ibm.com/developerworks/cn/aix/library/es-Javaperf/es-Javaperf4.html 最大化 AIX 上的 Java 性能,第 ...

  9. psutil documentation

    Quick links Home page Blog Download Forum What’s new About From project’s home page: psutil (python ...

随机推荐

  1. 使用yeoman起一个新项目(个人练习记录,勿喷!)

    1.首先安装yeoman:npm install -g yo2.yeoman需要generator来进行操作所以需要安装generator模块:npm install -g generator-web ...

  2. SQL Server DDL触发器

    DDL 触发器作用: DDL 触发器主要用于防止对数据库架构.视图.表.存储过程等进行的某些修改. DDL 触发器事件: DDL 触发器在创建用来监视并响应该数据库或服务器实例中的活动的事件通知时,可 ...

  3. APP移动端开发html模板

    移动端开发模板: 750的稿子除以75: <!DOCTYPE html> <html> <head> <meta charset="utf-8&qu ...

  4. 安装es6转码工具babel,具体步骤

    新建文件夹:testBabel 全局安装Babel:npm install babel-cli -g //babel的命令会成为全局变量,可以直接使用,一般全局后还要装本地(本工程目录) 初始化:np ...

  5. appium不同姿势安装

    一 桌面版(打开很慢,常用于辅助元素定位) 1.官网下载window版本: 2.直接点击图标即可打开  

  6. 【1】Kali Linux的安装及配置

    爱生活就得够GEEK. ---------------------------------------------------------------完美的分割线------------------- ...

  7. 好的博客参考之Spring

    https://blog.csdn.net/bao19901210/article/details/41724355

  8. Ubuntu16.04配置Android SDK环境

    下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html(注意32位与64位,我 ...

  9. @RequestMapping @SessionAttributes @ModelAttribute注解用法

    简介: @RequestMapping RequestMapping是一个用来处理请求地址映射的注解,可用于类或方法上.用于类上,表示类中的所有响应请求的方法都是以该地址作为父路径. RequestM ...

  10. C/C++结构体语法总结

    转自:http://blog.csdn.net/dawn_after_dark/article/details/73555562 结构体简介 结构体属于聚合数据类型的一类,它将不同的数据类型整合在一起 ...