From 4bfb634c15c9f5fc9b393f77dac5fe55fe6d9a80 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Sat, 4 May 2013 14:38:37 -0700 Subject: [PATCH] Hack pt-query-digest to write events to a file each time it runs. --- bin/pt-query-digest | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/pt-query-digest b/bin/pt-query-digest index bd7c8f30..cf28de85 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -13504,7 +13504,12 @@ sub main { } } # sample - if ( $o->get('output') =~ /slowlog/i ) { +# XXX +# if ( $o->get('output') =~ /slowlog/i ) { +my $utc_ts = ts(time, 1); +$utc_ts =~ s/:/_/g; +my $events_file = "/tmp/slow.log-$utc_ts"; +open my $events_fh, '>', $events_file or die "Cannot open $events_file: $OS_ERROR"; my $w = new SlowLogWriter(); $pipeline->add( name => '--output slowlog', @@ -13512,11 +13517,11 @@ sub main { my ( $args ) = @_; my $event = $args->{event}; PTDEBUG && _d('callback: --output slowlog'); - $w->write(*STDOUT, $event); + $w->write($events_fh, $event); return $args; }, ); - } # print +# } # print # Finally, add aggregator obj for each groupby attrib to the callbacks. # These aggregating objs should be the last pipeline processes.