linux io tools
linux 下我們可以通過iostat 從整體上來觀察io的情況,但是這個不能跟蹤到某個process。
iotop是一個類似top的檢測process IO 的Python 專案,如果有興趣,大家可以研究一下。
iotop是一個類似top的檢測process IO 的Python 專案,如果有興趣,大家可以研究一下。
但是對於那種多執行緒的應用,如mysql,還需要深入一點的工具,pt-ioprofile就是這樣的一個:
[root@oel58 percona-toolkit-2.1.9]# man pt-ioprofile
PT-IOPROFILE(1) User Contributed Perl Documentation PT-IOPROFILE(1)
[root@oel58 percona-toolkit-2.1.9]# man pt-ioprofile
PT-IOPROFILE(1) User Contributed Perl Documentation PT-IOPROFILE(1)
NAME
pt-ioprofile - Watch process IO and print a table of file and I/O activity.
pt-ioprofile - Watch process IO and print a table of file and I/O activity.
SYNOPSIS
Usage: pt-ioprofile [OPTIONS] [FILE]
Usage: pt-ioprofile [OPTIONS] [FILE]
pt-ioprofile does two things: 1) get lsof+strace for -s seconds, 2) aggregate the result. If you specify a FILE, then step 1) is not performed.
RISKS
The following section is included to inform. users about the potential risks, whether known or unknown, of using this tool. The two main cate-
gories of risks are those created by the nature of the tool (e.g. read-only tools vs. read-write tools) and those created by bugs.
The following section is included to inform. users about the potential risks, whether known or unknown, of using this tool. The two main cate-
gories of risks are those created by the nature of the tool (e.g. read-only tools vs. read-write tools) and those created by bugs.
pt-ioprofile is a read-only tool, so your data is not at risk. However, it works by attaching "strace" to the process using "ptrace()", which
will make it run very slowly until "strace" detaches. In addition to freezing the server, there is also some risk of the process crashing or
performing badly after "strace" detaches from it, or indeed of "strace" not detaching cleanly and leaving the process in a sleeping state. As
a result, this should be considered an intrusive tool, and should not be used on production servers unless you are comfortable with that.
will make it run very slowly until "strace" detaches. In addition to freezing the server, there is also some risk of the process crashing or
performing badly after "strace" detaches from it, or indeed of "strace" not detaching cleanly and leaving the process in a sleeping state. As
a result, this should be considered an intrusive tool, and should not be used on production servers unless you are comfortable with that.
At the time of this release, we know of no bugs that could cause serious harm to users.
The authoritative source for updated information is always the online issue tracking system. Issues that affect this tool will be marked as
such. You can see a list of such issues at the following URL: <http://www.percona.com/bugs/pt-ioprofile>.
such. You can see a list of such issues at the following URL: <http://www.percona.com/bugs/pt-ioprofile>.
See also "BUGS" for more information on filing bugs and getting help.
下面是一些例子,因為這個工具預設是針對mysql的,所以沒有指定process id:
[root@oel58 percona-toolkit-2.1.1]# perl pt-ioprofile
Sat Mar 9 17:15:19 CST 2013
Tracing process ID 5805
total read open close getdents64 _llseek fcntl64 filename
0.001335 0.000000 0.000213 0.000153 0.000830 0.000000 0.000139 /var/lib/mysql/
0.000578 0.000139 0.000088 0.000074 0.000000 0.000277 0.000000 /var/lib/mysql/performance_schema/db.opt
0.000464 0.000000 0.000075 0.000107 0.000215 0.000000 0.000067 /var/lib/mysql/test/
0.000318 0.000000 0.000318 0.000000 0.000000 0.000000 0.000000 /var/lib/mysql/test/db.opt
0.000185 0.000000 0.000185 0.000000 0.000000 0.000000 0.000000 /var/lib/mysql/mysql/db.opt
[root@oel58 percona-toolkit-2.1.1]# perl pt-ioprofile -cell sizes
Sat Mar 9 17:16:06 CST 2013
Tracing process ID 5805
total read pread64 pwrite64 fsync open close _llseek filename
262144 0 0 262144 0 0 0 0 /var/lib/mysql/ibdata1
8192 0 0 8192 0 0 0 0 /var/lib/mysql/ib_logfile0
472 441 31 0 0 0 0 0 /var/lib/mysql/test/aa.frm
[root@oel58 percona-toolkit-2.1.1]# perl pt-ioprofile
Sat Mar 9 17:15:19 CST 2013
Tracing process ID 5805
total read open close getdents64 _llseek fcntl64 filename
0.001335 0.000000 0.000213 0.000153 0.000830 0.000000 0.000139 /var/lib/mysql/
0.000578 0.000139 0.000088 0.000074 0.000000 0.000277 0.000000 /var/lib/mysql/performance_schema/db.opt
0.000464 0.000000 0.000075 0.000107 0.000215 0.000000 0.000067 /var/lib/mysql/test/
0.000318 0.000000 0.000318 0.000000 0.000000 0.000000 0.000000 /var/lib/mysql/test/db.opt
0.000185 0.000000 0.000185 0.000000 0.000000 0.000000 0.000000 /var/lib/mysql/mysql/db.opt
[root@oel58 percona-toolkit-2.1.1]# perl pt-ioprofile -cell sizes
Sat Mar 9 17:16:06 CST 2013
Tracing process ID 5805
total read pread64 pwrite64 fsync open close _llseek filename
262144 0 0 262144 0 0 0 0 /var/lib/mysql/ibdata1
8192 0 0 8192 0 0 0 0 /var/lib/mysql/ib_logfile0
472 441 31 0 0 0 0 0 /var/lib/mysql/test/aa.frm
另外,對於mysql 5.5 及以上,如果你開啟了Performance Schema ,這個database裡也記錄了一些跟mysql有關的io資訊
File I/O Summaries:
file_summary_by_event_name: File events summarized per event name
file_summary_by_instance: File events summarized per file instance
file_summary_by_event_name: File events summarized per event name
file_summary_by_instance: File events summarized per file instance
不過Performance Schema作為新生事情,記錄的資訊還是比較少,佔用的資源也稍微有點多,bug方面還不清楚,很多比較成熟的公司都還沒開始用。
轉載一個關於iotop工具使用方法:http://www.vmcd.org/2013/03/linux-tools-part-4-monitor-process-io-state/
iotop是一個類似top的檢測process IO 的Python 專案。可以在這裡下載到原始碼,可以在這裡找到具體的說明。下面做一個演示:
首先下載原始碼,要求python version>=2.6
首先下載原始碼,要求python version>=2.6
wget http://guichaz.free.fr/iotop/files/iotop-0.5.tar.gz
wget http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz
編譯python
[root@oel58 tmp]# cd /tmp/Python-2.6.6
[root@oel58 Python-2.6.6]#./configure && make && make install
....
checking for %zd printf() format support... yes
checking for socklen_t... yes
編譯完成之後,編譯iotop 原始碼
[root@oel58 tmp]# cd iotop-0.5
[root@oel58 iotop-0.5]# ./setup.py install
running install
running build
————————————————————–
[root@oel58 bin]# ./iotop --only
Total DISK READ : 0.00 B/s | Total DISK WRITE : 255.17 M/s
Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 256.64 M/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
16389 be/4 root 0.00 B/s 48.40 M/s 0.00 % 11.61 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
16418 be/4 root 0.00 B/s 58.64 M/s 0.00 % 11.55 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
16359 be/4 root 0.00 B/s 73.66 M/s 0.00 % 3.48 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
6756 be/4 root 0.00 B/s 0.00 B/s 0.00 % 5.97 % [flush-8:0]
16418 be/4 root 0.00 B/s 21.15 M/s 0.00 % 4.52 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
16447 be/4 root 0.00 B/s 23.91 M/s 0.00 % 3.02 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
109 be/4 root 3.54 K/s 1030.75 K/s 0.00 % 2.36 % [kjournald]
16359 be/4 root 0.00 B/s 22.91 M/s 0.00 % 1.69 % dd if /dev/zero of /tmp/temp.txt bs 1M count 10000
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.
經測試py version >2.6即可,此外需要說明如果kernel version < 2.6.20 會出現如下問題:
Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s
Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 16.26 K/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
CONFIG_TASK_DELAY_ACCT not enabled in kernel, cannot determine SWAPIN and IO %
strace iotop主要呼叫的python模組
open("/usr/local/lib/python2.6/lib-dynload/_socket.so", O_RDONLY) = 9
open("/usr/local/lib/python2.6/lib-dynload/_ssl.so", O_RDONLY|O_LARGEFILE) = 8
open("/usr/local/lib/python2.6/site-packages/iotop/vmstat.py", O_RDONLY|O_LARGEFILE) = 5
open("/usr/local/lib/python2.6/site-packages/iotop/vmstat.pyc", O_RDONLY|O_LARGEFILE) = 6
open("/usr/local/lib/python2.6/lib-dynload/cStringIO.so", O_RDONLY) = 7
open("/usr/local/lib/python2.6/lib-dynload/cStringIO.so", O_RDONLY|O_LARGEFILE) = 6
.....
iotop 對python的依賴性過高,以及對於version的要求過於嚴格,導致了通用性和移植性的下降。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-755961/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux安裝VMware ToolsLinux
- Kali Linux安裝VMware ToolsLinux
- LINUX下安裝VMware toolsLinux
- Tools:Linux下的SYSSTAT工具Linux
- linux下install vmware toolsLinux
- Linux IO模型Linux模型
- 在 Linux 中安裝 VMware ToolsLinux
- 【IO】Linux下的五種IO模型Linux模型
- linux的IO模型Linux模型
- linux IO理解-1Linux
- android-tools adb for ARM LinuxAndroidLinux
- VMware Server和Linux 5安VMware ToolsServerLinux
- Linux 上安裝和培植VMWARE TOOLSLinux
- 如何在Linux下更新安裝VMware ToolsLinux
- Linux攻略:正確安裝VMWARE TOOLS(轉)Linux
- Linux下正確安裝 VMWARE TOOLS(轉)Linux
- Linux C 檔案IOLinux
- Linux IO排程方法Linux
- Linux檔案IO操作Linux
- 【Linux】基礎IO(下)!!!Linux
- 【Linux】基礎IO(上)!!!Linux
- Linux系統磁碟IOLinux
- Linux 效能監測:IOLinux
- 簡述Linux磁碟IOLinux
- Linux程式設計學習筆記 | Linux IO學習[2] – 標準IOLinux程式設計筆記
- Linux作業系統中安裝VMware ToolsLinux作業系統
- <摘錄>linux檔案IOLinux
- linux 系統IO 排程Linux
- oracle toolsOracle
- 容器內的Linux診斷工具0x.toolsLinux
- 給VMware上的Linux系統安裝VMware ToolsLinux
- 在linux作業系統下安裝vmware toolsLinux作業系統
- Install VMware Tools in a Linux Guest(摘自vmware幫助文件)Linux
- Linux 效能優化之 IO 篇Linux優化
- Linux 的 Socket IO 模型趣解Linux模型
- Linux下開發-IO複用Linux
- linux 同步IO: sync、fsync與fdatasyncLinux
- Linux 下的五種 IO 模型Linux模型