Linux iotop工具简介
iotop的简介:
iotop是一款开源、免费的用来监控磁盘I/O使用状况的类似top命令的工具,iotop可以监控进程的I/O信息。它是Python语言编写的,与iostat工具比较,iostat是系统级别的IO监控,而iotop是进程级别IO监控。目前最新的版本为iotop 0.6。其官方网址http://guichaz.free.fr/iotop/
iotop的安装:
注意,iotop的安装有前提条件(如果操作系统不满足这些条件,iotop无法正确安装):
1:内核版本为2.6.20或更高版本
2:Python 2.7或更高的版本
官方文档的详细介绍如下:
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的yum安装
yum安装是最简单、快捷的。前提条件是你有配置yum的源配置。
[root@DB-Server ~]# python -V
Python 2.7.5
[root@DB-Server ~]# uname -a
Linux DB-Server 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@DB-Server ~]#
[root@DB-Server ~]# yum -y install iotop
iotop的源码安装
wget http://guichaz.free.fr/iotop/files/iotop-0.6.tar.bz2
tar -xvf iotop-0.6.tar.gz
cd iotop-0.6
python setup.py build
python setup.py install
iotop的参数
# iotop --help
Usage: /usr/local/sbin/iotop [OPTIONS]
DISK READ and DISK WRITE are the block I/O bandwidth used during the sampling
period. SWAPIN and IO are the percentages of time the thread spent respectively
while swapping in and waiting on I/O more generally. PRIO is the I/O priority at
which the thread is running (set using the ionice command).
Controls: left and right arrows to change the sorting column, r to invert the
sorting order, o to toggle the --only option, p to toggle the --processes
option, a to toggle the --accumulated option, i to change I/O priority, q to
quit, any other key to force a refresh.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-o, --only only show processes or threads actually doing I/O
-b, --batch non-interactive mode
-n NUM, --iter=NUM number of iterations before ending [infinite]
-d SEC, --delay=SEC delay between iterations [1 second]
-p PID, --pid=PID processes/threads to monitor [all]
-u USER, --user=USER users to monitor [all]
-P, --processes only show processes, not all threads
-a, --accumulated show accumulated I/O instead of bandwidth
-k, --kilobytes use kilobytes instead of a human friendly unit
-t, --time add a timestamp on each line (implies --batch)
-q, --quiet suppress some lines of header (implies --batch)
|
参数 |
长参数 |
参数描述 |
|
--version |
显示版本号 |
|
|
-h |
--help |
显示帮助信息 |
|
-o |
--only |
只显示正在产生I/O的进程或线程,运行过程中,可以通过按o随时切换 |
|
-b |
--batch |
非交互模式下运行,一般用来记录日志。 |
|
-n NUM |
--iter=NUM |
设置监控(显示)NUM次,主要用于非交互模式。默认无限 |
|
-d SEC |
--delay=SEC |
设置显示的间隔秒数,支持非整数 |
|
-p PID |
--pid=PID |
只显示指定进程(PID)的信息 |
|
-u USER |
--user=USER |
显示指定的用户的进程的信息 |
|
-P |
--processes |
只显示进程,不显示所有线程 |
|
-a |
--accumulated |
累积的I/O,显示从iotop启动后每个进程累积的I/O总数,便于诊断问题 |
|
-k |
--kilobytes |
显示使用KB单位 |
|
-t |
--time |
非交互模式下,加上时间戳。 |
|
-q |
--quiet |
只在第一次监测时显示列名. 去除头部一些行:这个参数可以设置最多3次来移除头部行:-q列头部只在最初交互显示一次;-qq列头部不显示;-qqq,I/O的总结不显示 |
iotop的快捷键
r:反向排序,
o:切换至选项--only,
p:切换至--processes选项,
a:切换至--accumulated选项
q:退出
i:改变线程的优先级
iotop的例子
1:只显示正在产生I/O的进程
# iotop -o

2:使用非交互模式将iotop命令输出信息写入日志
#nohup iotop -b -o -n 10 -d 5 -t > /tmp/iotop.log &
3:借助iotop命令找到消耗I/O最高的进程,然后通过进程找到其正在执行的SQL语句
# iotop -oP
PID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
11741 be/4 oracle 4.70 M/s 0.00 B/s 0.00 % 98.60 % ora_s004_SCM2
11739 be/4 oracle 66.99 M/s 0.00 B/s 0.00 % 93.30 % ora_s005_SCM2
11741 be/4 oracle 21.76 M/s 0.00 B/s 0.00 % 91.78 % ora_s006_SCM2
11743 be/4 oracle 4.87 M/s 3.78 M/s 0.00 % 27.74 % ora_s007_SCM2
11745 be/4 oracle 62.39 K/s 0.00 B/s 0.00 % 2.88 % ora_s008_SCM2
11733 be/4 oracle 39.00 K/s 0.00 B/s 0.00 % 2.08 % ora_s002_SCM2
11697 be/4 oracle 0.00 B/s 1879.61 K/s 0.00 % 0.30 % ora_dbw0_SCM2
11699 be/4 oracle 0.00 B/s 102.36 K/s 0.00 % 0.20 % ora_lgwr_SCM2
在找到消耗I/O最大的进程后,找出ORACLE进程正在执行的SQL语句
SQL> @getsql_by_spid.sql
Enter value for pid: 11741
old 13: WHERE c.spid = '&pid'))
new 13: WHERE c.spid = '11741'))
SQL_TEXT
--------------------------------------------
...............................(实际环境中,这里会输出SQL语句)
getsql_by_spid.sql脚本如下所示:
SELECT /*+ ORDERED */
sql_text
FROM v$sqltext a
WHERE (a.hash_value, a.address) IN (
SELECT DECODE (sql_hash_value,
0, prev_hash_value,
sql_hash_value
),
DECODE (sql_hash_value, 0, prev_sql_addr, sql_address)
FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = '&pid'))
ORDER BY piece ASC
/
这里只简单列了几个例子,因为iotop命令非常简单,了解iotop的参数和快捷方式后,基本上只需根据实际需求去获取进程或信息的I/O信息,剩下就是分析判断了。
Linux iotop工具简介的更多相关文章
- Windows/Linux下磁盘使用的图形化工具简介
Windows/Linux下磁盘使用的图形化工具简介 如何以图形界面查看磁盘及分区的大小及剩余容量呢?今天我为大家介绍两款Windows/Linux下磁盘使用的图形化工具分别是Spacesniff ...
- IP地址简介及Linux网络管理工具
IP地址简介 IP地址又叫网络地址也称逻辑地址,由32位2进制数组成,分4段每段8位,由10进制数表示,范围0~,段与段之间用点隔开采用点分十进制的表示法,在一个网络中ip地址是唯一的,IP地址最主要 ...
- Linux性能工具介绍
l Linux性能工具介绍 p CPU高 p 磁盘I/O p 网络 p 内存 p 应用程序跟踪 l 操作系统与应用程序的关系比喻为“唇亡齿寒”一点不为过 l 应用程序的性能问题/功能问 ...
- sed 工具简介
sed 工具简介sed 可以分析 Standard Input (STDIN) 的数据, 然后将数据经过处理后,再将他输出到 standrad out (STDOUT) 的一个工具. 至于处理呢?可以 ...
- redis redis常用命令及内存分析总结(附RedisClient工具简介
redis常用命令及内存分析总结(附RedisClient工具简介 by:授客 QQ:1033553122 redis-cli工具 查看帮助 连接redis数据库 常用命令 exists key se ...
- (转)Synopsys工具简介
DC Ultra--Design Compiler的最高版本 在Synopsys软件中完整的综合方案的核心是DC UltraTM,对所有设计而言它也是最好级别的综合平台.DC Ultra添加了全面的数 ...
- 新一代 Linux 文件系统 btrfs 简介
https://www.ibm.com/developerworks/cn/linux/l-cn-btrfs/ Btrfs 简介 文件系统似乎是内核中比较稳定的部分,多年来,人们一直使用 ext2/3 ...
- Linux系统入门简介<1>
linux系统入门简介 我们为什么要学习Linux? 在介绍Linux的历史前,我想先针对大家如何对Linux的发音说一下.我发现我身边的朋友对Linux的发音大致有这么几种: "里那克斯& ...
- [转帖]linux lsof 用法简介
linux lsof 用法简介 https://www.cnblogs.com/saneri/p/5333333.html 1.简介: lsof(list open files)是一个列出当前系统打开 ...
随机推荐
- docker学习笔记---基本命令
[root@docker ~]# docker Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Opt ...
- 【红宝书】第20章.JSON
JSON是一种轻量级的数据格式.JSON使用JS语法的子集表示对象.数组.字符串.数值.布尔值和null,不支持undefined JSON.stringify() // JSON.stringi ...
- 爬取b站互动视频信息
首先分辨视频是不是互动视频可以看 https://api.bilibili.com/x/player.so?id=cid:1&aid=89017 这个api返回的xml中的 <inter ...
- php的swoole和rpc区别
RPC是远程过程调用(Remote Procedure Call)的缩写形式. SAP系统RPC调用的原理其实很简单,有一些类似于三层构架的C/S系统,第三方的客户程序通过接口调用SAP内部的标准或自 ...
- Python活力练习Day1
Day1:输入年月日,判断这一天是这一年的第几天 eg: input : 2019-02-01 output : 32 data = list(input('please input ...
- 激光炸弹 HYSBZ - 1218
激光炸弹 HYSBZ - 1218 Time limit:10000 ms Memory limit:165888 kB OS:Linux Source:HNOI2003 一种新型的激光炸弹,可以摧毁 ...
- Oracle模糊查询CONCAT参数个数无效
在使用MyBatis操作Oracle数据库的时候,写模糊查询突然发现原本在MySql中正确的代码,在Oracle中报错,参数个数无效 <if test="empId!=null and ...
- 获取input type=file 的文件内容(纯文本)
一.获取input type=file 的文件内容(纯文本) 1.需求一 通过点击其他事件,来触发 文件选择框(限定格式为 .c 文件),而不是手动鼠标点击触发. [思路:] step1:将 inpu ...
- 嵌入Canvas App到Dynamics 365 Customer Engagement(Model-Driven App)中,创造更多可能!
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...
- 华为开发者联盟 方舟编译器 DevEco IDE
华为开发者联盟 https://developer.huawei.com/consumer/cn/ 方舟编译器是为支持多种编程语言.多种芯片平台的联合编译.运行而设计的统一编程平台,包含编译器.工具链 ...