9 Apr 2012

How to get a query-digest report from TCPdump on a set time

Note to self

Getting a query-digest report for 20 seconds worth of tcp traffic on linux
(no special slow log/microslow patch needed):
tcpdump -s 65535 -x -nn -q -tttt -i any -c 99999 port 3306 | pt-query-digest --type tcpdump --run-time 20s

thanks to aaron brown

Connect to Anemometer instead of using slow log
#crontab entry
*/5 * * * * tcpdump -s 65535 -x -nn -q -tttt -i any -c 99999 port 3306 | pt-query-digest --type tcpdump --run-time 20s --user=anemometer --password=superSecurePass --review h=db.example.com,D=slow_query_log,t=global_query_review --review-history h=db.example.com,D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg})"