1. 程式人生 > >pt-ioprofile

pt-ioprofile

pt-ioprofile

pt-ioprofile是屬於percona-toolkit中的一個工具,用strace和lsof來查監視進程的IO情況並打印表文件和活動IO,默認監視mysqld進程30秒


警告和風險:

pt-ioprofile可能會凍結服務,crash進程,是進程變得更糟糕,或者使進程休眠。

pt-ioprofile是一個有幹擾的工具,一般不用在生產環境中,除非你能理解和接受風險。


格式:

pt-ioprofile [OPTIONS] [FILE]


默認參數:

--aggregate The aggregate function, either C<sum> or C<avg>.


--cell The cell contents.

有三個值:

count Count of I/O operations

sizes Sizes of I/O operations

times I/O operation timing(默認)


--group-by The group-by item.

有三個值:

all Summarize into a single line of output

filename One line of output per filename (默認)

pid One line of output per process ID


--profile-pid The PID to profile, overrides L<"--profile-process">.

#指定監控的進程號

--profile-process The process name to profile.

指定監控的進程名

--run-time How long to profile.

#監控時長,默認30S

--save-samples Filename to save samples in; these can be used for later analysis.


例:


#用sysbench插入測試數據

[[email protected] lua]# sysbench --time=20 --threads=4 --mysql-host=localhost --mysql-user=root --mysql-password=‘147258‘ --mysql-db=sbtest --tables=10 --table_size=100000 /home/mysql/sysbench-1.0.3/src/lua/oltp_insert.lua prepare


#監控mysqld進程相關的IO:

[[email protected] sysbench-1.0.3]# pt-ioprofile --run-time=5

Thu Jun 1 22:46:29 CST 2017

Tracing process ID 5875

total pread read pwrite write fsync open close lseek ftruncate filename

4.774836 2.253120 0.000000 1.855958 0.000000 0.665758 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/ibdata1

0.873437 0.000000 0.000000 0.000000 0.293659 0.000000 0.000000 0.000000 0.000045 0.579733 /data/mysql/mysql3306/data/innodb_status.5875

0.615918 0.000000 0.000000 0.000000 0.000000 0.615918 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/undo001

0.420569 0.420518 0.000000 0.000000 0.000000 0.000051 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/undo002

0.224583 0.000000 0.000000 0.000000 0.000000 0.224583 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/sbtest/sbtest4.ibd

0.033272 0.000000 0.033259 0.000000 0.000000 0.000000 0.000000 0.000000 0.000013 0.000000 /data/mysql/mysql3306/logs/mysql-bin.000035

0.028929 0.000000 0.000000 0.000000 0.000000 0.028929 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/mysql/innodb_index_stats.ibd

0.025752 0.000000 0.000000 0.000000 0.000000 0.025752 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/sbtest/sbtest1.ibd

0.007142 0.000000 0.000000 0.000000 0.000000 0.007142 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/undo003

0.006129 0.000000 0.000000 0.000318 0.000000 0.005811 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/ib_logfile0

0.004302 0.000000 0.000000 0.000000 0.000000 0.004302 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/sbtest/sbtest2.ibd

0.000350 0.000000 0.000152 0.000000 0.000000 0.000000 0.000119 0.000079 0.000000 0.000000 /dev/urandom

0.000180 0.000000 0.000000 0.000000 0.000180 0.000000 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/general.log

0.000135 0.000000 0.000000 0.000000 0.000000 0.000135 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/sbtest/sbtest3.ibd

0.000053 0.000000 0.000000 0.000000 0.000000 0.000053 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/mysql/innodb_table_stats.ibd

0.000030 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000030 0.000000 /data/mysql/mysql3306/tmp/ib49MzXQ

0.000024 0.000000 0.000000 0.000000 0.000024 0.000000 0.000000 0.000000 0.000000 0.000000 /data/mysql/mysql3306/data/error.log


本文出自 “10979687” 博客,請務必保留此出處http://10989687.blog.51cto.com/10979687/1931780

pt-ioprofile