码迷,mamicode.com
首页 > 其他好文 > 详细

iotop详解

时间:2018-05-02 20:52:21      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:user   targe   time   右箭头   友好   inux   需要   交换   pytho   

 

 

有时我们希望知道到底哪个进程产生了IO,这个时候就需要iotop这个工具了。
它的输出和top命令类似,简单直观。官网:http://guichaz.free.fr/iotop/
需要Python 2.5(及以上版本)和 Linux kernel 2.6.20(及以上版本),TASK_DELAY_ACCT,CONFIG_TASKSTATS,TASK_IO_ACCOUNTING,CONFIG_VM_EVENT_COUNTERS这些内核选项开启。

官方说明:

Linux has always been able to show how much I/O was going on (the bi and bo columns of the vmstat 1 command)。

Iotop is a Python program with a top like UI used to show of behalf of which process is the I/O going on. It requires Python ≥ 2.7 and a Linux kernel ≥ 2.6.20 with the TASK_DELAY_ACCT CONFIG_TASKSTATS, TASK_IO_ACCOUNTING and CONFIG_VM_EVENT_COUNTERS options on.

安装iotop
[root@localhost ~]# yum -y install iotop

 

直接执行

Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s
TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND    
    1 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % init
    2 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kthreadd]
    3 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [migration/0]
    4 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [ksoftirqd/0]
    5 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [stopper/0]
    6 rt/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [watchdog/0]
    7 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events/0]
    8 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events/0]
    9 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events_long/0]
   10 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [events_power_ef]
   11 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [cgroup]
   12 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [khelper]
   13 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [netns]
   14 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [async/mgr]
   15 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [pm]
   16 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [sync_supers]
   17 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [bdi-default]
   18 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kintegrityd/0]
   19 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kblockd/0]
   20 be/4 root        0.00 B/s    0.00 B/s  0.00 %  0.00 % [kacpid]

............省略

  

看起来没有什么难度,照例把man翻译一遍:

名称 
       iotop - 简单的top类I/O监视器
总览
       iotop [OPTIONS]
描述
       iotop根据Linux内核(需要2.6.20及以上)来监测I/O,并且能显示当前进程/线程的I/O使用率。
       Linux内核build的事后哦,需要开启CONFIG_TASK_DELAY_ACCT和CONFIG_TASK_IO_ACCOUNTING选项,这些选项依赖于CONFIG_TASKSTATS。<br>
     <strong> <span style="font-size: 14px;"> 在采样周期里,iotop按列显示每个进程/线程的I/O读写带宽,同时也显示进程/线程做swap交换和等待I/O所占用的百分比。
       每一个进程都会显示I/O优先级(class/level),另外在最上面显示每个采样周期内的读写带宽。</span></strong><br><strong><span style="font-size: 14px;">
       使用左右箭头来改变排序,r用来改变排序顺序,o用来触发--only选项,p用来触发--processes选项。
       a用来触发--accumulated选项,q用来退出,i用来改变进程或线程的监测优先级,其它任继健是强制刷新。</span></strong>
 
选项
       --version 显示版本号然后退出
       -h, --help 显示帮助然后退出
       -o, --only 只显示正在产生I/O的进程或线程。除了传参,可以在运行过程中按o生效。
       -b, --batch 非交互模式,一般用来记录日志
       -n NUM, --iter=NUM 设置监测的次数,默认无限。在非交互模式下很有用
       -d SEC, --delay=SEC 设置每次监测的间隔,默认1秒,接受非整形数据例如1.1
       -p PID, --pid=PID 指定监测的进程/线程
       -u USER, --user=USER 指定监测某个用户产生的I/O
       -P, --processes 仅显示进程,默认iotop显示所有线程
       -a, --accumulated 显示累积的I/O,而不是带宽
       -k, --kilobytes 使用kB单位,而不是对人友好的单位。在非交互模式下,脚本编程有用。
       -t, --time 加上时间戳,非交互非模式。
       -q, --quiet 禁止头几行,非交互模式。有三种指定方式。
              -q     只在第一次监测时显示列名
              -qq    永远不显示列名。
              -qqq   永远不显示I/O汇总。

  

iotop详解

标签:user   targe   time   右箭头   友好   inux   需要   交换   pytho   

原文地址:https://www.cnblogs.com/what-/p/8981752.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!