mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-02-27 02:00:57 +08:00
PT-2289 - Allow pt-stalk do disable ps-lock-transactions data collection via parameter
- Adjusted the implementation - Created test cases
This commit is contained in:
21
bin/pt-stalk
21
bin/pt-stalk
@@ -971,7 +971,7 @@ collect_mysql_data_one() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ "${OPT_SKIP_COLLECTION}" =~ "mysqladmin" ]; then
|
||||
if ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "mysqladmin" ]]; then
|
||||
$CMD_MYSQLADMIN $EXT_ARGV ext -i$OPT_SLEEP_COLLECT -c$cnt >>"$d/$p-mysqladmin" &
|
||||
mysqladmin_pid=$!
|
||||
fi
|
||||
@@ -1016,7 +1016,7 @@ collect_system_data() {
|
||||
|
||||
collect_mysql_data_loop() {
|
||||
|
||||
if ! [ "${OPT_SKIP_COLLECTION}" =~ "processlist" ]; then
|
||||
if ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "processlist" ]]; then
|
||||
(echo $ts; $CMD_MYSQL $EXT_ARGV -e "SHOW FULL PROCESSLIST\G") \
|
||||
>> "$d/$p-processlist" &
|
||||
fi
|
||||
@@ -1025,16 +1025,16 @@ collect_mysql_data_loop() {
|
||||
>> "$d/$p-threads" &
|
||||
|
||||
if [ "$have_lock_waits_table" ]; then
|
||||
if ! [ "${OPT_SKIP_COLLECTION}" =~ "lock-waits" ]; then
|
||||
if ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "lock-waits" ]]; then
|
||||
(echo $ts; lock_waits "$d/lock_waits.running") >>"$d/$p-lock-waits" &
|
||||
fi
|
||||
if ! [ "${OPT_SKIP_COLLECTION}" =~ "transactions" ]; then
|
||||
if ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "transactions" ]]; then
|
||||
(echo $ts; transactions) >>"$d/$p-transactions" &
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${mysql_version}" '>' "5.6" ] && [ $ps_instrumentation_enabled == "yes" ] \
|
||||
&& ! [ "${OPT_SKIP_COLLECTION}" =~ "ps-locks-transactions" ]; then
|
||||
&& ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "ps-locks-transactions" ]]; then
|
||||
ps_locks_transactions "$d/$p-ps-locks-transactions"
|
||||
fi
|
||||
|
||||
@@ -1261,7 +1261,7 @@ innodb_status() {
|
||||
|
||||
local innostat=""
|
||||
|
||||
if ! [ "${OPT_SKIP_COLLECTION}" =~ "innodbstatus" ]; then
|
||||
if ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "innodbstatus" ]]; then
|
||||
$CMD_MYSQL $EXT_ARGV -e "SHOW /*!40100 ENGINE*/ INNODB STATUS\G" \
|
||||
>> "$d/$p-innodbstatus$n"
|
||||
grep "END OF INNODB" "$d/$p-innodbstatus$n" >/dev/null || {
|
||||
@@ -1285,7 +1285,7 @@ rocksdb_status() {
|
||||
has_rocksdb=`$CMD_MYSQL $EXT_ARGV -e "SHOW ENGINES" | grep -i 'rocksdb'`
|
||||
exit_code=$?
|
||||
|
||||
if [ $exit_code -eq 0 ] && ! [ "${OPT_SKIP_COLLECTION}" =~ "rocksdbstatus" ]; then
|
||||
if [ $exit_code -eq 0 ] && ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "rocksdbstatus" ]]; then
|
||||
$CMD_MYSQL $EXT_ARGV -e "SHOW ENGINE ROCKSDB STATUS\G" \
|
||||
>> "$d/$p-rocksdbstatus$n" || rm -f "$d/$p-rocksdbstatus$n"
|
||||
fi
|
||||
@@ -1367,7 +1367,7 @@ collect_mysql_variables() {
|
||||
echo -e "\n$sql\n" >> $outfile
|
||||
$CMD_MYSQL $EXT_ARGV -e "$sql" >> $outfile
|
||||
|
||||
if ! [ "${OPT_SKIP_COLLECTION}" =~ "thread-variables" ]; then
|
||||
if ! [[ "${OPT_SKIP_COLLECTION[@]}" =~ "thread-variables" ]]; then
|
||||
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
|
||||
@@ -1741,11 +1741,12 @@ main() {
|
||||
fi
|
||||
|
||||
if [ "$OPT_SKIP_COLLECTION" ]; then
|
||||
local supported_skips="ps-locks-transactions,thread-variables,innodbstatus,lock-waits,mysqladmin,processlist,rocksdbstatus,transactions"
|
||||
local supported_skips=(ps-locks-transactions thread-variables innodbstatus lock-waits mysqladmin processlist rocksdbstatus transactions)
|
||||
IFS=',' read -ra skips <<< "$OPT_SKIP_COLLECTION"
|
||||
OPT_SKIP_COLLECTION=("${skips[*]}")
|
||||
for skip in "${skips[@]}"; do
|
||||
echo "$supported_skips" | grep -q "$skip"
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! [[ " ${supported_skips[@]} " =~ " ${skip} " ]]; then
|
||||
log "Invalid --skip-collection value: $skip, exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user