Merge branch '3.0' into pt-stalk-collect-prepared-statements-LP1642750

Conflicts:
	bin/pt-stalk
	lib/bash/collect.sh
This commit is contained in:
guriandoro
2017-06-10 11:45:33 -04:00
160 changed files with 16765 additions and 7328 deletions

View File

@@ -813,8 +813,8 @@ collect() {
>> "$d/$p-stacktrace"
fi
$CMD_MYSQL $EXT_ARGV -e 'SHOW GLOBAL VARIABLES' >> "$d/$p-variables" &
sleep .2
collect_mysql_variables "$d/$p-variables" &
sleep .5
local mysql_version="$(awk '/^version[^_]/{print substr($2,1,3)}' "$d/$p-variables")"
@@ -863,7 +863,7 @@ collect() {
local strace_pid=$!
fi
ps -eaf >> "$d/$p-ps" &
ps -eaF >> "$d/$p-ps" &
top -bn${OPT_RUN_TIME} >> "$d/$p-top" &
[ "$mysqld_pid" ] && _lsof $mysqld_pid >> "$d/$p-lsof" &
@@ -905,7 +905,8 @@ collect() {
log "Loop start: $(date +'TS %s.%N %F %T')"
local start_time=$(date +'%s')
local curr_time=$start_time
local ps_instrumentation_enabled=$($CMD_MYSQL $EXT_ARGV -e "SELECT ENABLED FROM performance_schema.setup_instruments WHERE NAME = 'transaction';" | sed '2q;d' | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
local ps_instrumentation_enabled=$($CMD_MYSQL $EXT_ARGV -e 'SELECT ENABLED FROM performance_schema.setup_instruments WHERE NAME = "transaction";' \
| sed "2q;d" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
if [ $ps_instrumentation_enabled != "yes" ]; then
log "Performance Schema instrumentation is disabled"
@@ -957,9 +958,7 @@ collect() {
ps_locks_transactions "$d/$p-ps-locks-transactions"
fi
if [ "${mysql_version}" '>' "5.6" ]; then
(echo $ts; ps_prepared_statements) >> "$d/$p-prepared-statements" &
fi
slave_status "$d/$p-slave-status" "${mysql_version}"
curr_time=$(date +'%s')
done
@@ -1101,7 +1100,7 @@ innodb_status() {
ps_locks_transactions() {
local outfile=$1
mysql -e 'select @@performance_schema' | grep "1" &>/dev/null
$CMD_MYSQL $EXT_ARGV -e 'select @@performance_schema' | grep "1" &>/dev/null
if [ $? -eq 0 ]; then
local status="select t.processlist_id, ml.* from performance_schema.metadata_locks ml join performance_schema.threads t on (ml.owner_thread_id=t.thread_id)\G"
@@ -1125,13 +1124,50 @@ ps_locks_transactions() {
}
ps_prepared_statements() {
$CMD_MYSQL $EXT_ARGV -e "SELECT t.processlist_id, pse.* \
FROM performance_schema.prepared_statements_instances pse \
JOIN performance_schema.threads t \
ON (pse.OWNER_THREAD_ID=t.thread_id)\G"
slave_status() {
local outfile=$1
local mysql_version=$2
if [ "${mysql_version}" '<' "5.7" ]; then
local sql="SHOW SLAVE STATUS\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
else
local sql="SELECT * FROM performance_schema.replication_connection_configuration JOIN performance_schema.replication_applier_configuration USING(channel_name)\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="SELECT * FROM replication_connection_status\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="SELECT * FROM replication_applier_status JOIN replication_applier_status_by_coordinator USING(channel_name)\G"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
fi
}
collect_mysql_variables() {
local outfile=$1
local sql="SHOW GLOBAL VARIABLES"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.user_variables_by_thread order by thread_id, variable_name;"
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
sql="select * from performance_schema.status_by_thread order by thread_id, variable_name; "
echo -e "\n$sql\n" >> $outfile
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
}
# ###########################################################################
# End collect package
@@ -2299,7 +2335,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA.
=head1 VERSION
pt-stalk 3.0.1
pt-stalk 3.0.2
=cut