zoukankan      html  css  js  c++  java
  • pt-mext

    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                               0       0
    Aborted_connects                              0       0
    Binlog_cache_disk_use                         0       0
    Binlog_cache_use                              0       0
    Binlog_stmt_cache_disk_use                    0       0
    Binlog_stmt_cache_use                         0       0
    Bytes_received                             2243      35
    Bytes_sent                               158346    9246
    ......

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

    # pt-mext -- mysqladmin ext -i1 -c3

    Aborted_clients                               0       0
    Aborted_connects                              0       0
    Binlog_cache_disk_use                         0       0
    Binlog_cache_use                              0       0
    Binlog_stmt_cache_disk_use                    0       0
    Binlog_stmt_cache_use                         0       0
    Bytes_received                             1681    1716
    Bytes_sent                               102690  111935
    .....

    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 1  
    two 2
    
    one 2
    two 3
    three 4
    
    one 3
    two 4

    # pt-mext -- cat 4.txt 

    one                                           1 2
    two                                           2 3
  • 相关阅读:
    Byobu(tmux)的使用与定制
    Centos 编译安装Python 2.6
    how to set up the remote accout who to connection and management mysql server
    CentOS安装python2.6以及MySQLpython
    byobu "屏风" 简介 ,以及在CentOS下安装及日常使用
    /bin/rm: cannot remove `libtoolT': No such file or directory
    MySQLpython EnvironmentError: mysql_config not found | InfoEntropy
    几个逼真的页面 watch out
    Emerge详细解释
    微软Internet TV初体验
  • 原文地址:https://www.cnblogs.com/ivictor/p/6020418.html
Copyright © 2011-2022 走看看