Merge lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-should-also-gather-dmesg-output-1349086 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.12

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 629
Merged at revision: 633
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-should-also-gather-dmesg-output-1349086
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.12
Diff against target: 61 lines (+19/-0)
2 files modified
bin/pt-stalk (+10/-0)
lib/bash/collect.sh (+9/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-stalk-should-also-gather-dmesg-output-1349086
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+239256@code.launchpad.net

Description of the change

pt-stalk now gathers data from dmesg. It gathers from the last 60 seconds to keep the data relevant to the triggered event.

Note:
This proposal has been submitted before for 2.2.11 but was put on hold because changes were only made on pt-stalk and not made in lib/bash/collect.sh

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

Would be nice to test somehow? But I guess we don't test many of the various collections. So ok otherwise.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-stalk'
2--- bin/pt-stalk 2014-09-25 13:48:22 +0000
3+++ bin/pt-stalk 2014-10-22 18:33:46 +0000
4@@ -779,6 +779,7 @@
5 CMD_SYSCTL="${CMD_SYSCTL:-"$(_which sysctl)"}"
6 CMD_TCPDUMP="${CMD_TCPDUMP:-"$(_which tcpdump)"}"
7 CMD_VMSTAT="${CMD_VMSTAT:-"$(_which vmstat)"}"
8+CMD_DMESG="${CMD_DMESG:-"$(_which dmesg)"}"
9
10 [ -z "$CMD_SYSCTL" -a -x "/sbin/sysctl" ] && CMD_SYSCTL="/sbin/sysctl"
11
12@@ -862,6 +863,14 @@
13 if [ "$CMD_SYSCTL" ]; then
14 $CMD_SYSCTL -a >> "$d/$p-sysctl" &
15 fi
16+
17+ # collect dmesg events from 60 seconds ago until present
18+ if [ "$CMD_DMESG" ]; then
19+ local UPTIME=`cat /proc/uptime | awk '{ print $1 }'`
20+ local START_TIME=$(echo "$UPTIME 60" | awk '{print ($1 - $2)}')
21+ $CMD_DMESG | perl -ne 'm/\[\s*(\d+)\./; if ($1 > '${START_TIME}') { print }' >> "$d/$p-dmesg" &
22+ fi
23+
24 local cnt=$(($OPT_RUN_TIME / $OPT_SLEEP_COLLECT))
25 if [ "$CMD_VMSTAT" ]; then
26 $CMD_VMSTAT $OPT_SLEEP_COLLECT $cnt >> "$d/$p-vmstat" &
27@@ -876,6 +885,7 @@
28 $CMD_MPSTAT -P ALL $OPT_RUN_TIME 1 >> "$d/$p-mpstat-overall" &
29 fi
30
31+
32 $CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
33 local mysqladmin_pid=$!
34
35
36=== modified file 'lib/bash/collect.sh'
37--- lib/bash/collect.sh 2013-12-14 04:19:51 +0000
38+++ lib/bash/collect.sh 2014-10-22 18:33:46 +0000
39@@ -40,6 +40,7 @@
40 CMD_SYSCTL="${CMD_SYSCTL:-"$(_which sysctl)"}"
41 CMD_TCPDUMP="${CMD_TCPDUMP:-"$(_which tcpdump)"}"
42 CMD_VMSTAT="${CMD_VMSTAT:-"$(_which vmstat)"}"
43+CMD_DMESG="${CMD_DMESG:-"$(_which dmesg)"}"
44
45 # Try to find command manually.
46 [ -z "$CMD_SYSCTL" -a -x "/sbin/sysctl" ] && CMD_SYSCTL="/sbin/sysctl"
47@@ -146,6 +147,14 @@
48 if [ "$CMD_SYSCTL" ]; then
49 $CMD_SYSCTL -a >> "$d/$p-sysctl" &
50 fi
51+
52+ # collect dmesg events from 60 seconds ago until present
53+ if [ "$CMD_DMESG" ]; then
54+ local UPTIME=`cat /proc/uptime | awk '{ print $1 }'`
55+ local START_TIME=$(echo "$UPTIME 60" | awk '{print ($1 - $2)}')
56+ $CMD_DMESG | perl -ne 'm/\[\s*(\d+)\./; if ($1 > '${START_TIME}') { print }' >> "$d/$p-dmesg" &
57+ fi
58+
59 local cnt=$(($OPT_RUN_TIME / $OPT_SLEEP_COLLECT))
60 if [ "$CMD_VMSTAT" ]; then
61 $CMD_VMSTAT $OPT_SLEEP_COLLECT $cnt >> "$d/$p-vmstat" &

Subscribers

People subscribed via source and target branches

to all changes: