2019-04-21 11:50:48 +08:00

52 lines
3.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="iotop">iotop</h1>
<p>用来监视磁盘I/O使用状况的工具</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>iotop命令</strong> 是一个用来监视磁盘I/O使用状况的top类工具。iotop具有与top相似的UI其中包括PID、用户、I/O、进程等相关信息。Linux下的IO统计工具如iostatnmon等大多数是只能统计到per设备的读写情况如果你想知道每个进程是如何使用IO的就比较麻烦使用iotop命令可以很方便的查看。</p>
<p>iotop使用Python语言编写而成要求Python2.5及以上版本和Linux kernel2.6.20及以上版本。iotop提供有源代码及rpm包可从其官方主页下载。</p>
<h3 id="安装">安装</h3>
<p><strong>Ubuntu</strong></p>
<pre><code class="language-bash">apt-get install iotop</code></pre>
<p><strong>CentOS</strong></p>
<pre><code class="language-bash">yum install iotop</code></pre>
<p><strong>编译安装</strong></p>
<pre><code class="language-bash">wget http://guichaz.free.fr/iotop/files/iotop-0.4.4.tar.gz
tar zxf iotop-0.4.4.tar.gz
python setup.py build
python setup.py install
</code></pre>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">iotop选项</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-o只显示有io操作的进程
-b批量显示无交互主要用作记录到文件。
-n NUM显示NUM次主要用于非交互式模式。
-d SEC间隔SEC秒显示一次。
-p PID监控的进程pid。
-u USER监控的进程用户。</code></pre>
<p><strong>iotop常用快捷键</strong></p>
<ol type="1">
<li>左右箭头改变排序方式默认是按IO排序。</li>
<li>r改变排序顺序。</li>
<li>o只显示有IO输出的进程。</li>
<li>p进程/线程的显示方式的切换。</li>
<li>a显示累积使用量。</li>
<li>q退出。</li>
</ol>
<h3 id="实例">实例</h3>
<p>直接执行iotop就可以看到效果了</p>
<pre><code class="language-bash">Total DISK read: 0.00 B/s | Total DISK write: 0.00 B/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO&gt; command
1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init [3]
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 % [watchdog/0]
6 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/1]
7 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/1]
8 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/1]
9 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [events/0]
10 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [events/1]
11 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [khelper]
2572 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [bluetooth]</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->