首页 技术 正文
技术 2022年11月15日
0 收藏 843 点赞 4,464 浏览 1454 个字

pt-mext实现的功能比较简单,就是将mysqladmin输出的多次迭代的相同status变量值放到同一行输出。

参数很少,除了–help和–version外,只有一个–relative参数

short form: -r
Subtract each column from the previous column.

支持两种用法:

1. 直接对输出进行聚合

pt-mext -r — mysqladmin ext -i1 -c3

注意:上述命令中会有三次迭代,但只会输出第一次的结果,第二次和第一次相差的结果。

其中,

-i, –sleep=#       Execute commands repeatedly with a sleep between.

-c, –count=# Number of iterations to make. This works with -i (–sleep) only.

extended-status Gives an extended status message from the server

[root@localhost ~]# pt-mext -r -- mysqladmin ext -i1 -c3
Aborted_clients
Aborted_connects
Binlog_cache_disk_use
Binlog_cache_use
Binlog_stmt_cache_disk_use
Binlog_stmt_cache_use
Bytes_received
Bytes_sent
......

上述命令如果不加-r参数的话,则原样输出。

# pt-mext — mysqladmin ext -i1 -c3

Aborted_clients
Aborted_connects
Binlog_cache_disk_use
Binlog_cache_use
Binlog_stmt_cache_disk_use
Binlog_stmt_cache_use
Bytes_received
Bytes_sent
.....

2. 对文本文件进行聚合

pt-mext -r — cat mysqladmin-output.txt

注意:无论是否带-r参数,最后一次的迭代结果都不会纳入输出的范围。

关于它的原理,可参考官方文档的说明

pt-mext executes the COMMAND you specify, and reads through the result one line at a time. It places each line into a
temporary file. When it finds a blank line, it assumes that a new sample of SHOW GLOBAL STATUS is starting, and
it creates a new temporary file. At the end of this process, it has a number of temporary files. It joins the temporary
files together side-by-side and prints the result. If --relative option is given, it first subtracts each sample from
the one after it before printing results.

即每次迭代的结果都会放入到一个临时文件中,然后对这些临时文件进行join。

其实,该脚本的作用不限于mysqladmin的status变量值

如下所示:

# cat 4.txt

one
two one
two
three one
two

# pt-mext — cat 4.txt

one
two
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,031
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,860