mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
adds --fingerprint option for pt-kill - 1391240
This commit is contained in:
+13
-1
@@ -4007,7 +4007,7 @@ sub get_connected_slaves {
|
||||
die "You do not have the PROCESS privilege";
|
||||
}
|
||||
|
||||
$sql = 'SHOW PROCESSLIST';
|
||||
$sql = 'SHOW FULL PROCESSLIST';
|
||||
PTDEBUG && _d($dbh, $sql);
|
||||
grep { $_->{command} =~ m/Binlog Dump/i }
|
||||
map { # Lowercase the column names
|
||||
@@ -6567,6 +6567,7 @@ use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use POSIX qw(setsid);
|
||||
use List::Util qw(max);
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
use Data::Dumper;
|
||||
$Data::Dumper::Indent = 1;
|
||||
@@ -7101,6 +7102,11 @@ sub main {
|
||||
$query->{Id}, ($query->{Command} || 'NULL'), $query->{Time},
|
||||
($query->{Info} || 'NULL');
|
||||
}
|
||||
if ( $o->get('fingerprint') ) {
|
||||
my $fp = $qr->fingerprint($query->{'Info'});
|
||||
my $chksm = uc substr(md5_hex($fp), -16);
|
||||
print "Fingerprint: 0x$chksm\n";
|
||||
}
|
||||
if ( $o->get('execute-command') ) {
|
||||
exec_cmd($o->get('execute-command'));
|
||||
msg('Executed ' . $o->get('execute-command'));
|
||||
@@ -7487,6 +7493,12 @@ pt-kill does not provide any safeguards so code carefully!
|
||||
|
||||
It is permissible for the code to have side effects (to alter C<$event>).
|
||||
|
||||
=item --fingerprint
|
||||
|
||||
Prints a fingerprint (checksum) of the query that was just killed. This is
|
||||
equivalent to the fingerprint output of pt-query-digest. This allows
|
||||
cross-referencing the output of both tools.
|
||||
|
||||
=item --group-by
|
||||
|
||||
type: string
|
||||
|
||||
+11
-1
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 15;
|
||||
use Test::More tests => 16;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
@@ -137,6 +137,16 @@ like(
|
||||
"--match-all"
|
||||
);
|
||||
|
||||
# --fingerprint option
|
||||
$output = output(
|
||||
sub { pt_kill::main(@args, "$trunk/t/lib/samples/pl/recset011.txt", qw(--match-all --print --fingerprint)); }
|
||||
);
|
||||
like(
|
||||
$output,
|
||||
qr/0x69962191E64980E6/,
|
||||
'--fingerprint'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Live tests.
|
||||
# #############################################################################
|
||||
|
||||
Reference in New Issue
Block a user