mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 06:30:10 +00:00
PT-111 Collect MySQL variables
This commit is contained in:
29
bin/pt-stalk
29
bin/pt-stalk
@@ -813,8 +813,8 @@ collect() {
|
|||||||
>> "$d/$p-stacktrace"
|
>> "$d/$p-stacktrace"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$CMD_MYSQL $EXT_ARGV -e 'SHOW GLOBAL VARIABLES' >> "$d/$p-variables" &
|
collect_mysql_variables "$d/$p-variables" &
|
||||||
sleep .2
|
sleep .5
|
||||||
|
|
||||||
local mysql_version="$(awk '/^version[^_]/{print substr($2,1,3)}' "$d/$p-variables")"
|
local mysql_version="$(awk '/^version[^_]/{print substr($2,1,3)}' "$d/$p-variables")"
|
||||||
|
|
||||||
@@ -907,7 +907,8 @@ collect() {
|
|||||||
log "Loop start: $(date +'TS %s.%N %F %T')"
|
log "Loop start: $(date +'TS %s.%N %F %T')"
|
||||||
local start_time=$(date +'%s')
|
local start_time=$(date +'%s')
|
||||||
local curr_time=$start_time
|
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
|
if [ $ps_instrumentation_enabled != "yes" ]; then
|
||||||
log "Performance Schema instrumentation is disabled"
|
log "Performance Schema instrumentation is disabled"
|
||||||
@@ -1099,7 +1100,7 @@ innodb_status() {
|
|||||||
ps_locks_transactions() {
|
ps_locks_transactions() {
|
||||||
local outfile=$1
|
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
|
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"
|
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"
|
||||||
@@ -1123,6 +1124,26 @@ ps_locks_transactions() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
# End collect package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
@@ -75,8 +75,8 @@ collect() {
|
|||||||
# Get MySQL's variables if possible. Then sleep long enough that we probably
|
# Get MySQL's variables if possible. Then sleep long enough that we probably
|
||||||
# complete SHOW VARIABLES if all's well. (We don't want to run mysql in the
|
# complete SHOW VARIABLES if all's well. (We don't want to run mysql in the
|
||||||
# foreground, because it could hang.)
|
# foreground, because it could hang.)
|
||||||
$CMD_MYSQL $EXT_ARGV -e 'SHOW GLOBAL VARIABLES' >> "$d/$p-variables" &
|
collect_mysql_variables "$d/$p-variables" &
|
||||||
sleep .2
|
sleep .5
|
||||||
|
|
||||||
# Get the major.minor version number. Version 3.23 doesn't matter for our
|
# Get the major.minor version number. Version 3.23 doesn't matter for our
|
||||||
# purposes, and other releases have x.x.x* version conventions so far.
|
# purposes, and other releases have x.x.x* version conventions so far.
|
||||||
@@ -195,7 +195,7 @@ collect() {
|
|||||||
local ps_instrumentation_enabled=$($CMD_MYSQL $EXT_ARGV -e 'SELECT ENABLED FROM performance_schema.setup_instruments WHERE NAME = "transaction";' \
|
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/')
|
| sed "2q;d" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
|
||||||
|
|
||||||
if [ $ps_instrumentation_enabled != "yes"]; then
|
if [ $ps_instrumentation_enabled != "yes" ]; then
|
||||||
log "Performance Schema instrumentation is disabled"
|
log "Performance Schema instrumentation is disabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ collect() {
|
|||||||
(echo $ts; transactions) >>"$d/$p-transactions" &
|
(echo $ts; transactions) >>"$d/$p-transactions" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes"]; then
|
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ]; then
|
||||||
ps_locks_transactions "$d/$p-ps-locks-transactions"
|
ps_locks_transactions "$d/$p-ps-locks-transactions"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -428,6 +428,26 @@ ps_locks_transactions() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
# End collect package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
Reference in New Issue
Block a user