Merge lp:~percona-toolkit-dev/percona-toolkit/pt-sift-processlist-aggregation-fix-bug-945842 into lp:percona-toolkit/2.0

Proposed by Daniel Nichter
Status: Merged
Approved by: Daniel Nichter
Approved revision: 198
Merged at revision: 201
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-sift-processlist-aggregation-fix-bug-945842
Merge into: lp:percona-toolkit/2.0
Diff against target: 27 lines (+17/-1)
1 file modified
bin/pt-sift (+17/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-sift-processlist-aggregation-fix-bug-945842
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Baron Schwartz Pending
Review via email: mp+96170@code.launchpad.net

Description of the change

The old processlist format was one sample in a single file. The new one is many samples. This change makes awk exit after it sees the start of the second sample.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-sift'
2--- bin/pt-sift 2012-03-02 20:23:54 +0000
3+++ bin/pt-sift 2012-03-06 16:32:24 +0000
4@@ -356,7 +356,23 @@
5 fi
6 for word in State Command; do
7 echo " $word"
8- awk -F: "/^ *$word:/{print \$2}" "${PROCESSLIST_FILE}" \
9+ awk -F: -v column="$word" '
10+ BEGIN {
11+ regex = "^ *" column
12+ }
13+ {
14+ if ( $1 ~ regex ) {
15+ print $2;
16+ }
17+ # Newer versions of pt-stalk gather several samples. We will
18+ # analyze only the first sample.
19+ if ( $0 ~ /^TS/ ) {
20+ ts++;
21+ if (ts > 1) {
22+ exit
23+ }
24+ }
25+ }' "${PROCESSLIST_FILE}" \
26 | sort | uniq -c | sort -rn | head -n 5
27 done
28

Subscribers

People subscribed via source and target branches