Percona-Tookit工具包之pt-sift

 
Preface
 
    We've got a lot of files related with system performance which generated by pt-stalk in directory "/var/lib/pt-stalk" in my last blog.We can use "cat","more","less" to print the contents of them but it is really not convenient to do so.
 
Introduce
 
    pt-sift is the right tool helping us to retrieve diagnostic data easily.There're poor options of the tool to learn.Therefor,it's easy enough to sift the contents we need with no time.
 
Procedure
 
Usage
1 pt-sift FILE|PREFIX|DIRECTORY

 

Examples
 
Print the output of the files generated by pt-stalk.
 1 [root@zlm2 09:50:42 /var/lib/pt-stalk]
 2 #pt-sift
 3 Error:  is not a directory, and there are no pt-stalk files in the curent working directory (/var/lib/pt-stalk) with a  prefix.
 4 For more information, 'man pt-sift' or 'perldoc /usr/bin/pt-sift'.
 5 
 6 [root@zlm2 09:50:44 /var/lib/pt-stalk]
 7 #pt-sift /var/lib/pt-stalk
 8 
 9   2018_07_09_08_19_39  2018_07_09_08_24_39
10 
11 Select a timestamp from the list [2018_07_09_08_24_39] 2018_07_09_08_19_39
12 ======== zlm2 at 2018_07_09_08_19_39 DEFAULT (1 of 2) ========
13 --diskstats--
14   #ts device    rd_s rd_avkb rd_mb_s rd_mrg rd_cnc   rd_rt    wr_s wr_avkb wr_mb_s wr_mrg wr_cnc   wr_rt busy in_prg    io_s  qtime stime
15  {29} sda        2.4    16.9     0.0     0%    0.0     2.6    26.2    48.9     1.2    10%    0.1     4.7   3%      0    28.6    3.5   1.1
16  sda  0% 5% 0% . . . . . . . . . . . . . . . . . . . . . 20% 0% . . . .
17 --vmstat--
18 r b swpd  free buff  cache si so  bi   bo   in    cs us sy id wa st
19 7 5 5276 73004    0 569412  0  0  10  117   74   433  2  1 97  0  0
20 4 0 5604 72876    0 571420  2 11 213 1261 1423 11833 80 20  0  0  0
21 wa 0% . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22 --innodb--
23     txns: 3xnot (0s)
24     0 queries inside InnoDB, 0 queries in queue
25     Main thread: sleeping, pending reads 0, writes 0, flush 0
26     Log: lsn = 1144708398, chkp = 1127336399, chkp age = 17371999
27     Threads are waiting at:
28     Threads are waiting on:
29 --processlist--
30     State
31       6  
32       1  starting
33       1  executing
34     Command
35       6  Sleep
36       2  Query
37 --stack traces--
38     No stack trace file exists
39 --oprofile--
40     No opreport file exists
41     
42 //It won't exit until you input "q".
43 //Further more,you can input other keystrokes to navigate the contents you want.

 

Check the disk relevant output by press "q" in above output.
 1 ======== zlm2 at 2018_07_09_08_19_39 DISKSTATS (1 of 2) ========
 2 Starting /usr/bin/pt-diskstats
 3 
 4   #ts device    rd_s rd_avkb rd_mb_s rd_mrg rd_cnc   rd_rt    wr_s wr_avkb wr_mb_s wr_mrg wr_cnc   wr_rt busy in_prg    io_s  qtime stime
 5   1.0 sda       41.2    18.2     0.7     0%    0.1     3.4    24.7    35.0     0.8     0%    0.0     1.8   6%      0    65.8    1.9   0.9
 6   1.0 sda2      41.2    18.2     0.7     0%    0.1     3.4    20.6    42.0     0.8     0%    0.0     1.1   4%      0    61.7    2.0   0.6
 7   1.0 dm-0      41.2    18.2     0.7     0%    0.1     3.4    20.6    42.0     0.8     0%    0.0     2.1   6%      0    61.7    2.0   0.9
 8 
 9 //too many lines here,they've been ommited.
10 
11   #ts device    rd_s rd_avkb rd_mb_s rd_mrg rd_cnc   rd_rt    wr_s wr_avkb wr_mb_s wr_mrg wr_cnc   wr_rt busy in_prg    io_s  qtime stime
12  28.0 sda        0.0     0.0     0.0     0%    0.0     0.0    18.4    29.9     0.5     0%    0.0     1.0   2%      0    18.4    0.1   0.9
13  28.0 sda2       0.0     0.0     0.0     0%    0.0     0.0    14.6    37.9     0.5     0%    0.0     0.6   1%      0    14.6    0.1   0.5
14  28.0 dm-0       0.0     0.0     0.0     0%    0.0     0.0    14.6    37.9     0.5     0%    0.0     1.3   2%      0    14.6    0.1   1.1
15  28.0 dm-1       0.0     0.0     0.0     0%    0.0     0.0     0.0     0.0     0.0     0%    0.0     0.0   0%      0     0.0    0.0   0.0
16 
17   #ts device    rd_s rd_avkb rd_mb_s rd_mrg rd_cnc   rd_rt    wr_s wr_avkb wr_mb_s wr_mrg wr_cnc   wr_rt busy in_prg    io_s  qtime stimePress a key to continue or choose a different action

 

Check the innodb status relevant output by press "q",then press "i" in above output.
 1 Press a key to continue or choose a different action
 2 ======== zlm2 at 2018_07_09_08_19_39 INNODB (1 of 2) ========
 3 Viewing InnoDB files
 4 ... //Several otmitted blank rows here.
 5 *************************** 1. row ***************************
 6   Type: InnoDB
 7   Name: 
 8 Status: 
 9 =====================================
10 2018-07-09 08:19:40 0x7f7ce8211700 INNODB MONITOR OUTPUT
11 =====================================
12 Per second averages calculated from the last 20 seconds
13 -----------------
14 BACKGROUND THREAD
15 -----------------
16 srv_master_thread loops: 642 srv_active, 0 srv_shutdown, 18648 srv_idle
17 srv_master_thread log flush and writes: 19290
18 ----------
19 SEMAPHORES
20 ----------
21 OS WAIT ARRAY INFO: reservation count 2620
22 OS WAIT ARRAY INFO: signal count 2117
23 RW-shared spins 0, rounds 1009, OS waits 422
24 RW-excl spins 0, rounds 29932, OS waits 1071
25 RW-sx spins 198, rounds 5940, OS waits 137
26 Spin rounds per wait: 1009.00 RW-shared, 29932.00 RW-excl, 30.00 RW-sx
27 ------------
28 TRANSACTIONS
29 ------------
30 Trx id counter 363859
31 Purge done for trx's n:o < 363858 undo n:o < 0 state: running
32 History list length 360
33 LIST OF TRANSACTIONS FOR EACH SESSION:
34 ---TRANSACTION 421649654532384, not started
35 0 lock struct(s), heap size 1136, 0 row lock(s)
36 ... //Omitted.

 

Check the net relevant output by press "q",then press "n" in above output.
1 Press a key to continue or choose a different action
2 ======== zlm2 at 2018_07_09_08_19_39 NETWORK (1 of 2) ========
3 Source of connections to port 3306
4      12 192.168.1.101
5       2 
6 Status of connections to port 3306
7      12 ESTABLISHED
8       2 LISTEN
9 Press a key to continue or choose a different action

 

Check the first four samples of "show status" by press "m".
 1 ======== zlm2 at 2018_07_09_08_24_39 MEXT (2 of 2) ========
 2 Displaying the first 4 samples of SHOW STATUS counters
 3 ... //Several otmitted blank rows here.
 4 Aborted_clients                               3           0           0           0
 5 Aborted_connects                              0           0           0           0
 6 Binlog_cache_disk_use                         0           0           0           0
 7 Binlog_cache_use                         260350         275         262         286
 8 Binlog_stmt_cache_disk_use                    0           0           0           0
 9 Binlog_stmt_cache_use                        31           0           0           0
10 Bytes_received                        401068901      223306      212357      231011
11 Bytes_sent                          10433667031    11046014    10595838    11481359
12 Com_admin_commands                            2           0           0           0
13 Com_alter_db                                  0           0           0           0
14 Com_alter_db_upgrade                          0           0           0           0
15 Com_alter_event                               0           0           0           0
16 Com_alter_function                            0           0           0           0
17 Com_alter_instance                            0           0           0           0
18 Com_alter_procedure                           0           0           0           0
19 Com_alter_server                              0           0           0           0
20 Com_alter_table                               0           0           0           0
21 Com_alter_tablespace                          0           0           0           0
22 Com_alter_user                                1           0           0           0
23 Com_analyze                                   0           0           0           0
24 Com_assign_to_keycache                        0           0           0           0
25 Com_begin                                259973         274         263         286
26 ... //Omitted.

 

Check the file list by press "q",then press "0" in above output.
 1 ======== zlm2 at 2018_07_09_08_19_39 LIST (1 of 2) ========
 2 -rw-r--r-- 1 root root  17K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-df
 3 -rw-r--r-- 1 root root  139 Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-disk-space
 4 -rw-r--r-- 1 root root  15K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-diskstats
 5 -rw-r--r-- 1 root root    5 Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-hostname
 6 -rw-r--r-- 1 root root 4.3K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-innodbstatus1
 7 -rw-r--r-- 1 root root 4.5K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-innodbstatus2
 8 -rw-r--r-- 1 root root  33K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-interrupts
 9 -rw-r--r-- 1 root root  11K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-lsof
10 -rw-r--r-- 1 root root  37K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-meminfo
11 -rw-r--r-- 1 root root  384 Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-mutex-status1
12 -rw-r--r-- 1 root root  385 Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-mutex-status2
13 -rw-r--r-- 1 root root 1.1M Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-mysqladmin
14 -rw-r--r-- 1 root root  48K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-netstat
15 -rw-r--r-- 1 root root  51K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-netstat_s
16 -rw-r--r-- 1 root root 5.2K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-opentables1
17 -rw-r--r-- 1 root root 5.2K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-opentables2
18 -rw-r--r-- 1 root root  25K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-output
19 -rw-r--r-- 1 root root 9.7K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-pmap
20 -rw-r--r-- 1 root root  40K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-processlist
21 -rw-r--r-- 1 root root  25K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-procstat
22 -rw-r--r-- 1 root root  71K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-procvmstat
23 -rw-r--r-- 1 root root 8.4K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-ps
24 -rw-r--r-- 1 root root 290K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-slabinfo
25 -rw-r--r-- 1 root root  28K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-sysctl
26 -rw-r--r-- 1 root root 8.1K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-top
27 -rw-r--r-- 1 root root  73K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-transactions
28 -rw-r--r-- 1 root root  383 Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-trigger
29 -rw-r--r-- 1 root root  17K Jul  9 08:19 /var/lib/pt-stalk/2018_07_09_08_19_39-variables
30 -rw-r--r-- 1 root root 2.8K Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-vmstat
31 -rw-r--r-- 1 root root  325 Jul  9 08:20 /var/lib/pt-stalk/2018_07_09_08_19_39-vmstat-overall
32 
33 //It merely output the files relevant with the prefix("2018_07_09_08_19_39") you've specified.

 

Check all the contents of files by press "*" in above output.
 1 ======== zlm2 at 2018_07_09_08_19_39 VIEW (1 of 2) ========
 2 Viewing all files //This time we'll check all the contents in each file.
 3 ... //Several otmitted blank rows here.
 4 TS 1531117181.030895281 2018-07-09 08:19:41
 5 Filesystem              1K-blocks     Used Available Use% Mounted on
 6 /dev/mapper/centos-root   8775680  7993600    782080  92% /
 7 devtmpfs                   499536        0    499536   0% /dev
 8 tmpfs                      508740        0    508740   0% /dev/shm
 9 tmpfs                      508740     6716    502024   2% /run
10 tmpfs                      508740        0    508740   0% /sys/fs/cgroup
11 /dev/sda1                  508588   120796    387792  24% /boot
12 none                     90264572 83357056   6907516  93% /vagrant
13 TS 1531117182.002834196 2018-07-09 08:19:42
14 Filesystem              1K-blocks     Used Available Use% Mounted on
15 /dev/mapper/centos-root   8775680  7993772    781908  92% /
16 devtmpfs                   499536        0    499536   0% /dev
17 tmpfs                      508740        0    508740   0% /dev/shm
18 tmpfs                      508740     6716    502024   2% /run
19 tmpfs                      508740        0    508740   0% /sys/fs/cgroup
20 /dev/sda1                  508588   120796    387792  24% /boot
21 none                     90264572 83357056   6907516  93% /vagrant
22 TS 1531117183.011493818 2018-07-09 08:19:43
23 Filesystem              1K-blocks     Used Available Use% Mounted on
24 /dev/mapper/centos-root   8775680  7993792    781888  92% /
25 devtmpfs                   499536        0    499536   0% /dev
26 tmpfs                      508740        0    508740   0% /dev/shm
27 tmpfs                      508740     6716    502024   2% /run
28 tmpfs                      508740        0    508740   0% /sys/fs/cgroup
29 /dev/sda1                  508588   120796    387792  24% /boot
30 none                     90264572 83357056   6907516  93% /vagrant
31 TS 1531117184.019711999 2018-07-09 08:19:44
32 Filesystem              1K-blocks     Used Available Use% Mounted on
33 /dev/mapper/centos-root   8775680  7993820    781860  92% /
34 devtmpfs                   499536        0    499536   0% /dev
35 /var/lib/pt-stalk/2018_07_09_08_19_39-df (file 1 of 30) //There're 30 files in all relative to the prefix.

 

Summary
  • pt-sift is a tool used to quikly sift contents of the files generated by pt-stalk by variety.
  • pt-sift can impove your efficiency in retrieving huge amount of files by specifying prefix.
  • pt-sift relies on pt-stalk and even downloads the necessary tool when using the function of them,such as pt-diskstats,pt-mext,etc.
 
posted @ 2018-07-08 22:38  aaron8219  阅读(673)  评论(0编辑  收藏  举报