mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 13:40:07 +00:00
pt-ms & pt-stalk: Enable the standard mysql options
This commit is contained in:
@@ -347,14 +347,14 @@ _parse_command_line() {
|
|||||||
|
|
||||||
if [ "$next_opt_is_val" ]; then
|
if [ "$next_opt_is_val" ]; then
|
||||||
next_opt_is_val=""
|
next_opt_is_val=""
|
||||||
if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then
|
if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then
|
||||||
option_error "$real_opt requires a $required_arg argument"
|
option_error "$real_opt requires a $required_arg argument"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
val="$opt"
|
val="$opt"
|
||||||
opt_is_ok=1
|
opt_is_ok=1
|
||||||
else
|
else
|
||||||
if [ $(expr "$opt" : "-") -eq 0 ]; then
|
if [ $(expr "$opt" : "\-") -eq 0 ]; then
|
||||||
if [ -z "$ARGV" ]; then
|
if [ -z "$ARGV" ]; then
|
||||||
ARGV="$opt"
|
ARGV="$opt"
|
||||||
else
|
else
|
||||||
@@ -450,6 +450,46 @@ size_to_bytes() {
|
|||||||
# End parse_options package
|
# End parse_options package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
|
# ###########################################################################
|
||||||
|
# mysql_options package
|
||||||
|
# This package is a copy without comments from the original. The original
|
||||||
|
# with comments and its test file can be found in the Bazaar repository at,
|
||||||
|
# lib/bash/mysql_options.sh
|
||||||
|
# t/lib/bash/mysql_options.sh
|
||||||
|
# See https://launchpad.net/percona-toolkit for more information.
|
||||||
|
# ###########################################################################
|
||||||
|
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
mysql_options() {
|
||||||
|
local MYSQL_ARGS=""
|
||||||
|
if [ -n "$OPT_DEFAULTS_FILE" ]; then
|
||||||
|
MYSQL_ARGS="--defaults-file=$OPT_DEFAULTS_FILE"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_PORT" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --port=$OPT_PORT"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_SOCKET" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --socket=$OPT_SOCKET"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_HOST" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --host=$OPT_HOST"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_USER" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --user='$OPT_USER'"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_PASSWORD" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --password='$OPT_PASSWORD'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $MYSQL_ARGS
|
||||||
|
}
|
||||||
|
|
||||||
|
# ###########################################################################
|
||||||
|
# End mysql_options package
|
||||||
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# tmpdir package
|
# tmpdir package
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
@@ -788,7 +828,6 @@ collect_mysqld_instances () {
|
|||||||
echo "internal::oom_of_$pid $oom" >> "$variables_file"
|
echo "internal::oom_of_$pid $oom" >> "$variables_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
pids="$pids"
|
|
||||||
pids="$(echo $pids | sed -e 's/ /,/g')"
|
pids="$(echo $pids | sed -e 's/ /,/g')"
|
||||||
ps ww -p "$pids" 2>/dev/null
|
ps ww -p "$pids" 2>/dev/null
|
||||||
else
|
else
|
||||||
@@ -930,8 +969,13 @@ get_mysqldump_args () {
|
|||||||
collect_mysqld_executables () {
|
collect_mysqld_executables () {
|
||||||
local mysqld_instances="$1"
|
local mysqld_instances="$1"
|
||||||
|
|
||||||
|
local ps_opt="cmd="
|
||||||
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
|
ps_opt="command="
|
||||||
|
fi
|
||||||
|
|
||||||
for pid in $( grep '/mysqld' "$mysqld_instances" | awk '/^.*[0-9]/{print $1}' ); do
|
for pid in $( grep '/mysqld' "$mysqld_instances" | awk '/^.*[0-9]/{print $1}' ); do
|
||||||
ps -o cmd -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/' | grep -v '^CMD$'
|
ps -o $ps_opt -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/'
|
||||||
done | sort -u
|
done | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2185,7 +2229,7 @@ report_mysql_summary () {
|
|||||||
|| [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ]; then
|
|| [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ]; then
|
||||||
reply="y"
|
reply="y"
|
||||||
elif [ -t 0 -a -t 1 ]; then
|
elif [ -t 0 -a -t 1 ]; then
|
||||||
echo -n "Would you like to mysqldump -d the schema and analyze it? y/n "
|
printf "Would you like to mysqldump -d the schema and analyze it? y/n "
|
||||||
read reply
|
read reply
|
||||||
reply=${reply:-n}
|
reply=${reply:-n}
|
||||||
fi
|
fi
|
||||||
@@ -2193,7 +2237,7 @@ report_mysql_summary () {
|
|||||||
if [ -z "${OPT_DATABASES}" ] && [ -z "$OPT_READ_SAMPLES" ] \
|
if [ -z "${OPT_DATABASES}" ] && [ -z "$OPT_READ_SAMPLES" ] \
|
||||||
&& [ ! -e "$dir/mysqldump" ]; then
|
&& [ ! -e "$dir/mysqldump" ]; then
|
||||||
echo "There are ${num_dbs} databases. Would you like to dump all, or just one?"
|
echo "There are ${num_dbs} databases. Would you like to dump all, or just one?"
|
||||||
echo -n "Type the name of the database, or press Enter to dump all of them. "
|
printf "Type the name of the database, or press Enter to dump all of them. "
|
||||||
local dbtodump=""
|
local dbtodump=""
|
||||||
read dbtodump
|
read dbtodump
|
||||||
local trg_arg="$( get_mysqldump_args "$dir/mysql-variables" )"
|
local trg_arg="$( get_mysqldump_args "$dir/mysql-variables" )"
|
||||||
@@ -2320,6 +2364,7 @@ report_mysql_summary () {
|
|||||||
|
|
||||||
section "Configuration File"
|
section "Configuration File"
|
||||||
local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")"
|
local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")"
|
||||||
|
|
||||||
if [ -n "${cnf_file}" ]; then
|
if [ -n "${cnf_file}" ]; then
|
||||||
name_val "Config File" "${cnf_file}"
|
name_val "Config File" "${cnf_file}"
|
||||||
pretty_print_cnf_file "$dir/mysql-config-file"
|
pretty_print_cnf_file "$dir/mysql-config-file"
|
||||||
@@ -2376,6 +2421,14 @@ main() {
|
|||||||
# Prepending SIG to these doesn't work with NetBSD's sh
|
# Prepending SIG to these doesn't work with NetBSD's sh
|
||||||
trap sigtrap HUP INT TERM
|
trap sigtrap HUP INT TERM
|
||||||
|
|
||||||
|
local MYSQL_ARGS="$(mysql_options)"
|
||||||
|
EXT_ARGV="$EXT_ARGV $MYSQL_ARGS"
|
||||||
|
|
||||||
|
# Check if mysql and mysqldump are there, otherwise bail out early.
|
||||||
|
# But don't if they passed in --read-samples, since we don't need
|
||||||
|
# a connection then.
|
||||||
|
[ "$OPT_READ_SAMPLES" ] || check_mysql
|
||||||
|
|
||||||
local RAN_WITH="--sleep=$OPT_SLEEP --databases=$OPT_DATABASES --save-samples=$OPT_SAVE_SAMPLES"
|
local RAN_WITH="--sleep=$OPT_SLEEP --databases=$OPT_DATABASES --save-samples=$OPT_SAVE_SAMPLES"
|
||||||
|
|
||||||
_d "Starting $0 $RAN_WITH"
|
_d "Starting $0 $RAN_WITH"
|
||||||
@@ -2442,11 +2495,6 @@ if [ "${0##*/}" = "$TOOL" ] \
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if mysql and mysqldump are there, otherwise bail out early.
|
|
||||||
# But don't if they passed in --read-samples, since we don't need
|
|
||||||
# a connection then.
|
|
||||||
[ "$OPT_READ_SAMPLES" ] || check_mysql
|
|
||||||
|
|
||||||
main "${@:-""}"
|
main "${@:-""}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -2498,7 +2546,7 @@ and other scripting languages.
|
|||||||
To use, simply execute it. Optionally add a double dash and then the same
|
To use, simply execute it. Optionally add a double dash and then the same
|
||||||
command-line options you would use to connect to MySQL, such as the following:
|
command-line options you would use to connect to MySQL, such as the following:
|
||||||
|
|
||||||
pt-mysql-summary -- --user=root
|
pt-mysql-summary --user=root
|
||||||
|
|
||||||
The tool interacts minimally with the server upon which it runs. It assumes
|
The tool interacts minimally with the server upon which it runs. It assumes
|
||||||
that you'll run it on the same server you're inspecting, and therefore it
|
that you'll run it on the same server you're inspecting, and therefore it
|
||||||
@@ -2923,6 +2971,43 @@ Seconds to sleep when gathering status counters.
|
|||||||
|
|
||||||
Print tool's version and exit.
|
Print tool's version and exit.
|
||||||
|
|
||||||
|
=item --defaults-file
|
||||||
|
|
||||||
|
short form: -F; type: string
|
||||||
|
|
||||||
|
Only read mysql options from the given file. You must give an absolute
|
||||||
|
pathname.
|
||||||
|
|
||||||
|
=item --host
|
||||||
|
|
||||||
|
short form: -h; type: string; default: localhost
|
||||||
|
|
||||||
|
Host to connect to.
|
||||||
|
|
||||||
|
=item --password
|
||||||
|
|
||||||
|
short form: -p; type: string
|
||||||
|
|
||||||
|
Password to use when connecting.
|
||||||
|
|
||||||
|
=item --port
|
||||||
|
|
||||||
|
short form: -P; type: int
|
||||||
|
|
||||||
|
Port number to use for connection.
|
||||||
|
|
||||||
|
=item --socket
|
||||||
|
|
||||||
|
short form: -S; type: string
|
||||||
|
|
||||||
|
Socket file to use for connection.
|
||||||
|
|
||||||
|
=item --user
|
||||||
|
|
||||||
|
short form: -u; type: string
|
||||||
|
|
||||||
|
User for login if not current user.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 ENVIRONMENT
|
=head1 ENVIRONMENT
|
||||||
|
86
bin/pt-stalk
86
bin/pt-stalk
@@ -347,14 +347,14 @@ _parse_command_line() {
|
|||||||
|
|
||||||
if [ "$next_opt_is_val" ]; then
|
if [ "$next_opt_is_val" ]; then
|
||||||
next_opt_is_val=""
|
next_opt_is_val=""
|
||||||
if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then
|
if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then
|
||||||
option_error "$real_opt requires a $required_arg argument"
|
option_error "$real_opt requires a $required_arg argument"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
val="$opt"
|
val="$opt"
|
||||||
opt_is_ok=1
|
opt_is_ok=1
|
||||||
else
|
else
|
||||||
if [ $(expr "$opt" : "-") -eq 0 ]; then
|
if [ $(expr "$opt" : "\-") -eq 0 ]; then
|
||||||
if [ -z "$ARGV" ]; then
|
if [ -z "$ARGV" ]; then
|
||||||
ARGV="$opt"
|
ARGV="$opt"
|
||||||
else
|
else
|
||||||
@@ -450,6 +450,46 @@ size_to_bytes() {
|
|||||||
# End parse_options package
|
# End parse_options package
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
|
|
||||||
|
# ###########################################################################
|
||||||
|
# mysql_options package
|
||||||
|
# This package is a copy without comments from the original. The original
|
||||||
|
# with comments and its test file can be found in the Bazaar repository at,
|
||||||
|
# lib/bash/mysql_options.sh
|
||||||
|
# t/lib/bash/mysql_options.sh
|
||||||
|
# See https://launchpad.net/percona-toolkit for more information.
|
||||||
|
# ###########################################################################
|
||||||
|
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
mysql_options() {
|
||||||
|
local MYSQL_ARGS=""
|
||||||
|
if [ -n "$OPT_DEFAULTS_FILE" ]; then
|
||||||
|
MYSQL_ARGS="--defaults-file=$OPT_DEFAULTS_FILE"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_PORT" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --port=$OPT_PORT"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_SOCKET" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --socket=$OPT_SOCKET"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_HOST" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --host=$OPT_HOST"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_USER" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --user='$OPT_USER'"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_PASSWORD" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --password='$OPT_PASSWORD'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $MYSQL_ARGS
|
||||||
|
}
|
||||||
|
|
||||||
|
# ###########################################################################
|
||||||
|
# End mysql_options package
|
||||||
|
# ###########################################################################
|
||||||
|
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
# tmpdir package
|
# tmpdir package
|
||||||
# This package is a copy without comments from the original. The original
|
# This package is a copy without comments from the original. The original
|
||||||
@@ -1347,6 +1387,9 @@ if [ "${0##*/}" = "$TOOL" ] \
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local MYSQL_ARGS="$(mysql_options)"
|
||||||
|
EXT_ARGV="$EXT_ARGV $MYSQL_ARGS"
|
||||||
|
|
||||||
# Check that mysql and mysqladmin are in PATH. If not, we're
|
# Check that mysql and mysqladmin are in PATH. If not, we're
|
||||||
# already dead in the water, so don't bother with cmd line opts,
|
# already dead in the water, so don't bother with cmd line opts,
|
||||||
# just error and exit.
|
# just error and exit.
|
||||||
@@ -1416,7 +1459,7 @@ pt-stalk - Gather forensic data about MySQL when a problem occurs.
|
|||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
Usage: pt-stalk [OPTIONS] [-- MYSQL OPTIONS]
|
Usage: pt-stalk [OPTIONS] [-- EXTRA MYSQL OPTIONS]
|
||||||
|
|
||||||
pt-stalk watches for a trigger condition to become true, and then collects data
|
pt-stalk watches for a trigger condition to become true, and then collects data
|
||||||
to help in diagnosing problems. It is designed to run as a daemon with root
|
to help in diagnosing problems. It is designed to run as a daemon with root
|
||||||
@@ -1883,6 +1926,43 @@ want to use a higher verbosity level.
|
|||||||
|
|
||||||
Print tool's version and exit.
|
Print tool's version and exit.
|
||||||
|
|
||||||
|
=item --defaults-file
|
||||||
|
|
||||||
|
short form: -F; type: string
|
||||||
|
|
||||||
|
Only read mysql options from the given file. You must give an absolute
|
||||||
|
pathname.
|
||||||
|
|
||||||
|
=item --host
|
||||||
|
|
||||||
|
short form: -h; type: string; default: localhost
|
||||||
|
|
||||||
|
Host to connect to.
|
||||||
|
|
||||||
|
=item --password
|
||||||
|
|
||||||
|
short form: -p; type: string
|
||||||
|
|
||||||
|
Password to use when connecting.
|
||||||
|
|
||||||
|
=item --port
|
||||||
|
|
||||||
|
short form: -P; type: int
|
||||||
|
|
||||||
|
Port number to use for connection.
|
||||||
|
|
||||||
|
=item --socket
|
||||||
|
|
||||||
|
short form: -S; type: string
|
||||||
|
|
||||||
|
Socket file to use for connection.
|
||||||
|
|
||||||
|
=item --user
|
||||||
|
|
||||||
|
short form: -u; type: string
|
||||||
|
|
||||||
|
User for login if not current user.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 ENVIRONMENT
|
=head1 ENVIRONMENT
|
||||||
|
@@ -354,14 +354,14 @@ _parse_command_line() {
|
|||||||
|
|
||||||
if [ "$next_opt_is_val" ]; then
|
if [ "$next_opt_is_val" ]; then
|
||||||
next_opt_is_val=""
|
next_opt_is_val=""
|
||||||
if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then
|
if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then
|
||||||
option_error "$real_opt requires a $required_arg argument"
|
option_error "$real_opt requires a $required_arg argument"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
val="$opt"
|
val="$opt"
|
||||||
opt_is_ok=1
|
opt_is_ok=1
|
||||||
else
|
else
|
||||||
if [ $(expr "$opt" : "-") -eq 0 ]; then
|
if [ $(expr "$opt" : "\-") -eq 0 ]; then
|
||||||
if [ -z "$ARGV" ]; then
|
if [ -z "$ARGV" ]; then
|
||||||
ARGV="$opt"
|
ARGV="$opt"
|
||||||
else
|
else
|
||||||
|
@@ -43,7 +43,6 @@ collect_mysqld_instances () {
|
|||||||
echo "internal::oom_of_$pid $oom" >> "$variables_file"
|
echo "internal::oom_of_$pid $oom" >> "$variables_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
pids="$pids"
|
|
||||||
pids="$(echo $pids | sed -e 's/ /,/g')"
|
pids="$(echo $pids | sed -e 's/ /,/g')"
|
||||||
ps ww -p "$pids" 2>/dev/null
|
ps ww -p "$pids" 2>/dev/null
|
||||||
else
|
else
|
||||||
@@ -201,8 +200,13 @@ get_mysqldump_args () {
|
|||||||
collect_mysqld_executables () {
|
collect_mysqld_executables () {
|
||||||
local mysqld_instances="$1"
|
local mysqld_instances="$1"
|
||||||
|
|
||||||
|
local ps_opt="cmd="
|
||||||
|
if [ "$(uname -s)" = "Darwin" ]; then
|
||||||
|
ps_opt="command="
|
||||||
|
fi
|
||||||
|
|
||||||
for pid in $( grep '/mysqld' "$mysqld_instances" | awk '/^.*[0-9]/{print $1}' ); do
|
for pid in $( grep '/mysqld' "$mysqld_instances" | awk '/^.*[0-9]/{print $1}' ); do
|
||||||
ps -o cmd -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/' | grep -v '^CMD$'
|
ps -o $ps_opt -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/'
|
||||||
done | sort -u
|
done | sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
lib/bash/mysql_options.sh
Normal file
52
lib/bash/mysql_options.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# This program is copyright 2011 Percona Inc.
|
||||||
|
# Feedback and improvements are welcome.
|
||||||
|
#
|
||||||
|
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||||
|
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
|
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar
|
||||||
|
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
|
||||||
|
# licenses.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||||
|
# Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
# ###########################################################################
|
||||||
|
# mysql_options package
|
||||||
|
# ###########################################################################
|
||||||
|
|
||||||
|
# Package: mysql_options
|
||||||
|
# Handle --defaults-file & related options
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
mysql_options() {
|
||||||
|
local MYSQL_ARGS=""
|
||||||
|
if [ -n "$OPT_DEFAULTS_FILE" ]; then
|
||||||
|
MYSQL_ARGS="--defaults-file=$OPT_DEFAULTS_FILE"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_PORT" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --port=$OPT_PORT"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_SOCKET" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --socket=$OPT_SOCKET"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_HOST" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --host=$OPT_HOST"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_USER" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --user='$OPT_USER'"
|
||||||
|
fi
|
||||||
|
if [ -n "$OPT_PASSWORD" ]; then
|
||||||
|
MYSQL_ARGS="$MYSQL_ARGS --password='$OPT_PASSWORD'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $MYSQL_ARGS
|
||||||
|
}
|
||||||
|
|
||||||
|
# ###########################################################################
|
||||||
|
# End mysql_options package
|
||||||
|
# ###########################################################################
|
@@ -398,7 +398,7 @@ _parse_command_line() {
|
|||||||
|
|
||||||
if [ "$next_opt_is_val" ]; then
|
if [ "$next_opt_is_val" ]; then
|
||||||
next_opt_is_val=""
|
next_opt_is_val=""
|
||||||
if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then
|
if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then
|
||||||
option_error "$real_opt requires a $required_arg argument"
|
option_error "$real_opt requires a $required_arg argument"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -406,7 +406,7 @@ _parse_command_line() {
|
|||||||
opt_is_ok=1
|
opt_is_ok=1
|
||||||
else
|
else
|
||||||
# If option does not begin with a hyphen (-), it's a filename, etc.
|
# If option does not begin with a hyphen (-), it's a filename, etc.
|
||||||
if [ $(expr "$opt" : "-") -eq 0 ]; then
|
if [ $(expr "$opt" : "\-") -eq 0 ]; then
|
||||||
if [ -z "$ARGV" ]; then
|
if [ -z "$ARGV" ]; then
|
||||||
ARGV="$opt"
|
ARGV="$opt"
|
||||||
else
|
else
|
||||||
|
@@ -1489,6 +1489,7 @@ report_mysql_summary () {
|
|||||||
# ########################################################################
|
# ########################################################################
|
||||||
section "Configuration File"
|
section "Configuration File"
|
||||||
local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")"
|
local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")"
|
||||||
|
|
||||||
if [ -n "${cnf_file}" ]; then
|
if [ -n "${cnf_file}" ]; then
|
||||||
name_val "Config File" "${cnf_file}"
|
name_val "Config File" "${cnf_file}"
|
||||||
pretty_print_cnf_file "$dir/mysql-config-file"
|
pretty_print_cnf_file "$dir/mysql-config-file"
|
||||||
|
34
t/lib/bash/mysql_options.sh
Normal file
34
t/lib/bash/mysql_options.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
plan 3
|
||||||
|
|
||||||
|
TMPFILE="$TEST_PT_TMPDIR/parse-opts-output"
|
||||||
|
TOOL="pt-mysql-summary"
|
||||||
|
PT_TMPDIR="$TEST_PT_TMPDIR"
|
||||||
|
|
||||||
|
source "$LIB_DIR/log_warn_die.sh"
|
||||||
|
source "$LIB_DIR/parse_options.sh"
|
||||||
|
source "$LIB_DIR/mysql_options.sh"
|
||||||
|
|
||||||
|
cnf="/tmp/12345/my.sandbox.cnf"
|
||||||
|
|
||||||
|
parse_options "$PERCONA_TOOLKIT_BRANCH/bin/pt-mysql-summary" --defaults-file $cnf
|
||||||
|
is "$OPT_DEFAULTS_FILE" "$cnf" "--defaults-file works"
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# --host's default works
|
||||||
|
# ############################################################################
|
||||||
|
|
||||||
|
parse_options "$PERCONA_TOOLKIT_BRANCH/bin/pt-mysql-summary"
|
||||||
|
is "$OPT_HOST" "localhost" "--host has default: localhost"
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Short forms work
|
||||||
|
# ############################################################################
|
||||||
|
|
||||||
|
parse_options "$PERCONA_TOOLKIT_BRANCH/bin/pt-mysql-summary" -F $cnf
|
||||||
|
is "$OPT_DEFAULTS_FILE" "$cnf" "-F works"
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Done
|
||||||
|
# ############################################################################
|
1
t/lib/bash/mysql_options.t
Symbolic link
1
t/lib/bash/mysql_options.t
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../util/test-bash-functions
|
Reference in New Issue
Block a user