Skip to main content

iotop

iotop

在统信服务器操作系统中,使用类似top的i/o监视器。

概述

iotop命令是一个用来监视磁盘I/O使用状况的top类工具。iotop具有与top相似的用户界面接口,其中包括PID、用户、I/O、进程等相关信息。Linux下的IO统计工具如iostat、nmon等大多数是只能统计到每个设备的读写情况,如果需要知道每个进程是如何使用IO的,可以执行iotop命令进行查看。

命令介绍

在终端界面,通过root用户执行dnf install iotop iotop-help(仅e版中存在iotop-help)命令安装iotop和iotop-help软件包。完成后,执行man 8 iotop命令,可查看其他更多参数及其含义。

IOTOP(8) System Manager's Manual IOTOP(8) NAME iotop- simple top-like I/0 monitor SYNOPSIS iotop [OPTIONS] DESCRIPTION otop watches I/ousage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/0 usage by processes or threads on the system.At Least the CONFIG_TASK_DELAY ACCT, CONFIG_TASK_TO_ACCOUNTING, CON FIG_TASKSTATS and CONFIG_VM EVEN_CONER options needto be enabledin your Linux kernel build configuration. iotop displays columns for the I/0 bandwidth read and written by each process/thread during the sampling period.It also displays the percentage of time the thread/process spent while swapping n and whle waiting on /0.For each process its I/0 priority(class/level) is shown. In addition,the total /0 bandwidth read and written during the sampling period is displayed at the top of the inter face.Total DISK READ and Total DISK WRITE values represent total read and write bandwidth between processes and kerne threads on the one side and kernel block device subsystem on the other.While Actual DISK READ and Actual DISK WRITE val esepresent corresponding bandwidths for actual disk /0 etween kernel block device subsystem and underlying hardware (HDD,SSD,etc.).Thus Total and Actual values may not be equal at any given moment of time due to data caching and I/ operations reordering that take place inside Linux kernel. Use the left and right arrows to change the sorting,r to reverse the sorting order,o to toggle the --only option,p to toggle the-processes option,a to toggle the-accumulated option,q to quit or i to change the priority of a thread or a process' thread(s).Any other key will force a refresh. OPTIONS --version Show the version number and exit -h,--help show usage information and exit -0,--only Onty show processes or threads actually doing /0,instead of showing all processes or threads.This can be dynam- ically toggled by pressing o. -b,--batch Turn on non-interactive mode.Useful for logging I/0 usage over time. -n NUM,--iter=NUM Set the number of iterations before quitting (never quit by default).This is most useful in non-interactive


### 功能测试

以root用户身份登录系统,在终端1界面,执行iotop命令,显示系统中操作磁盘I/O的进程的实时状态。

Total DISK READ 0.00B/s Total DISK WRITE: 929.85K/s Actual DISK READ: 0.00 B/s Actual DISK WRITE: 0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN COMMAND I0> 6403 be/4 root 0.00B/s 0.00 B/s 0.00% 0.01% [kwo rker/0:2-events] 545 be/4 root 0.00 B/s 929.85K/s 0.00% 0.00 systemd-journald 1 be/4 root 0.00 B/s 0.00 B/s 0.00% 0.00 systemd --Switched-root --system --deserialize 18 root 2 be/4 0.00 B/s 0.00 B/s 0.00% 0.00% [kthreadd] 3 be/0 root 0.00 B/s 0.00 B/s 0.00% 0.00% [rcu_gp] [rcu par gp] 4 be/0 root 0.00 B/s 0.00 B/s 0.00% 0.00% [kworker/0:0H-kbLockd] 6 be/0 root 0.00 B/s 0.00 B/s 0.00% 0.00% be/0 root 0.00% 8 0.00 B/s 0.00 B/s 0.00% [mm_percpu_wq] 9 be/4 root 0.00 B/s 0.00 B/s 0.00% 0.00% [ksoftirgd/0] 10 be/4 root 0.00 B/s 0.00B/s 0.00% 0.00% [rcu_sched] 西 「-LL1


切换到终端2界面,执行如下命令,对磁盘进行写操作,终端1中iotop状态实时显示监控磁盘的写速度。

```bash
cd /home

dd if=/dev/zero of=bigfile bs=1M count=5000

切换到终端2界面,执行如下命令,对磁盘进行读操作,终端1中iotop状态实时显示监控磁盘的读速度。

cd /home

dd if=bigfile of=/dev/null bs=1M