mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 21:09:14 +00:00
(more syncing)
This commit is contained in:
@@ -537,7 +537,6 @@ fuzzy_formula='
|
||||
}'
|
||||
|
||||
fuzz () {
|
||||
_d "fuzz: $1"
|
||||
echo $1 | awk "{fuzzy_var=\$1; ${fuzzy_formula} print fuzzy_var;}"
|
||||
}
|
||||
|
||||
@@ -842,6 +841,38 @@ collect_internal_vars () {
|
||||
echo "pt-summary-internal-symbols $has_symbols" >> "$file"
|
||||
}
|
||||
|
||||
get_mysqldump_for () {
|
||||
local file="$1"
|
||||
local args="$2"
|
||||
local dbtodump="${3:---all-databases}"
|
||||
|
||||
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
||||
--skip-add-locks --skip-add-drop-table --compact \
|
||||
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
||||
${args} "${dbtodump}" > "$file"
|
||||
}
|
||||
|
||||
get_mysqldump_args () {
|
||||
local file="$1"
|
||||
local trg_arg=""
|
||||
|
||||
if $CMD_MYSQLDUMP --help --verbose 2>&1 | grep triggers >/dev/null; then
|
||||
_d "mysqldump supports triggers"
|
||||
trg_arg="--routines"
|
||||
fi
|
||||
|
||||
if [ "${trg_arg}" ]; then
|
||||
local triggers="--skip-triggers"
|
||||
local trg=$(get_var "pt-summary-internal-trigger_count" "$file" )
|
||||
if [ -n "${trg}" ] && [ "${trg}" -gt 0 ]; then
|
||||
_d "We have triggers to dump"
|
||||
triggers="--triggers"
|
||||
fi
|
||||
trg_arg="${trg_arg} ${triggers}";
|
||||
fi
|
||||
echo "${trg_arg}"
|
||||
}
|
||||
|
||||
collect_mysql_info () {
|
||||
local dir="$1"
|
||||
local prefix="${2:-percona-toolkit}"
|
||||
@@ -891,34 +922,30 @@ collect_mysql_info () {
|
||||
# End collect_mysql_info package
|
||||
# ###########################################################################
|
||||
|
||||
# ########################################################################
|
||||
# Some global setup is necessary for cross-platform compatibility, even
|
||||
# when sourcing this script for testing purposes.
|
||||
# ########################################################################
|
||||
# ###########################################################################
|
||||
# report_mysql_info 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/report_mysql_info.sh
|
||||
# t/lib/bash/report_mysql_info.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
TOOL="pt-mysql-summary"
|
||||
|
||||
CMD_MYSQL="$(_which mysql)"
|
||||
CMD_MYSQLDUMP="$( _which mysqldump )"
|
||||
set -u
|
||||
|
||||
# Accepts a number of seconds, and outputs a d+h:m:s formatted string
|
||||
secs_to_time () {
|
||||
echo "$1" | awk '{
|
||||
printf( "%d+%02d:%02d:%02d", $1 / 86400, ($1 % 86400) / 3600, ($1 % 3600) / 60, $1 % 60);
|
||||
}'
|
||||
}
|
||||
|
||||
# Returns true if a variable exists
|
||||
var_exists () {
|
||||
local varname="$1"
|
||||
local file="$2"
|
||||
grep "${varname}" "${file}" >/dev/null 2>&1;
|
||||
}
|
||||
|
||||
# Returns "Enabled", "Disabled", or "Not Supported" depending on whether the
|
||||
# variable exists and is ON or enabled. You can pass 2nd and 3rd variables to
|
||||
# control whether the variable should be 'gt' (numeric greater than) or 'eq'
|
||||
# (string equal) to some value.
|
||||
feat_on() {
|
||||
local file="$1"
|
||||
if var_exists "$2" "${file}" ; then
|
||||
@@ -960,7 +987,6 @@ get_table_cache () {
|
||||
echo ${table_cache:-0}
|
||||
}
|
||||
|
||||
# Gets the status of a plugin, or returns "Not found"
|
||||
get_plugin_status () {
|
||||
local file="$1"
|
||||
local plugin="$2"
|
||||
@@ -970,13 +996,7 @@ get_plugin_status () {
|
||||
echo ${status:-"Not found"}
|
||||
}
|
||||
|
||||
# ##############################################################################
|
||||
# Functions for parsing specific files and getting desired info from them.
|
||||
# These are called from within main() and are separated so they can be tested
|
||||
# easily.
|
||||
# ##############################################################################
|
||||
|
||||
# Parses the output of 'ps -e -o args | grep mysqld' or 'ps auxww...'
|
||||
_NO_FALSE_NEGATIVES=""
|
||||
parse_mysqld_instances () {
|
||||
local file="$1"
|
||||
@@ -989,8 +1009,6 @@ parse_mysqld_instances () {
|
||||
grep '/mysqld ' "$file" | while read line; do
|
||||
local pid=$(echo "$line" | awk '{print $2;}')
|
||||
for word in ${line}; do
|
||||
# Some grep doesn't have -o, so I have to pull out the words I want by
|
||||
# looking at each word
|
||||
if echo "${word}" | grep -- "--socket=" > /dev/null; then
|
||||
socket="$(echo "${word}" | cut -d= -f2)"
|
||||
fi
|
||||
@@ -1011,7 +1029,6 @@ parse_mysqld_instances () {
|
||||
done
|
||||
}
|
||||
|
||||
# Gets the MySQL system time. Uses input from $MYSQL_VARIABLES_FILE.
|
||||
get_mysql_timezone () {
|
||||
local file="${1:-$MYSQL_VARIABLES_FILE}"
|
||||
local tz="$(get_var time_zone "${file}")"
|
||||
@@ -1021,14 +1038,12 @@ get_mysql_timezone () {
|
||||
echo "${tz}"
|
||||
}
|
||||
|
||||
# Gets the MySQL system version.
|
||||
get_mysql_version () {
|
||||
local file="$1"
|
||||
name_val Version "$(get_var version "${file}") $(get_var version_comment "${file}")"
|
||||
name_val "Built On" "$(get_var version_compile_os "${file}") $(get_var version_compile_machine "${file}")"
|
||||
}
|
||||
|
||||
# Gets the system start and uptime in human readable format.
|
||||
get_mysql_uptime () {
|
||||
local uptime="$1"
|
||||
local restart="$2"
|
||||
@@ -1036,11 +1051,9 @@ get_mysql_uptime () {
|
||||
echo "${restart} (up ${uptime})"
|
||||
}
|
||||
|
||||
# Summarizes the output of SHOW MASTER LOGS.
|
||||
summarize_binlogs () {
|
||||
local file="$1"
|
||||
local size="$(awk '{t += $2} END{printf "%0.f\n", t}' "$file")"
|
||||
cat "$file" >> ~/bluhbluh.txt
|
||||
name_val "Binlogs" $(wc -l "$file")
|
||||
name_val "Zero-Sized" $(grep -c '\<0$' "$file")
|
||||
name_val "Total Size" $(shorten ${size} 1)
|
||||
@@ -1051,20 +1064,14 @@ format_users () {
|
||||
awk '{printf "%d users, %d anon, %d w/o pw, %d old pw\n", $1, $2, $3, $4}' "${file}"
|
||||
}
|
||||
|
||||
# Print out binlog_do_db and binlog_ignore_db
|
||||
format_binlog_filters () {
|
||||
local file="$1"
|
||||
name_val "binlog_do_db" "$(cut -f3 "$file")"
|
||||
name_val "binlog_ignore_db" "$(cut -f4 "$file")"
|
||||
}
|
||||
|
||||
# Takes as input a file that has two samples of SHOW STATUS, columnized next to
|
||||
# each other. Outputs fuzzy-ed numbers:
|
||||
# absolute, all-time per second, and per-second over the interval between the
|
||||
# samples. Omits any rows that are all zeroes.
|
||||
format_status_variables () {
|
||||
local file="$1"
|
||||
# First, figure out the intervals.
|
||||
utime1="$(awk '/Uptime /{print $2}' "$file")";
|
||||
utime2="$(awk '/Uptime /{print $3}' "$file")";
|
||||
awk "
|
||||
@@ -1106,15 +1113,6 @@ format_status_variables () {
|
||||
}" "$file"
|
||||
}
|
||||
|
||||
# Slices the processlist a bunch of different ways. The processlist should be
|
||||
# created with the \G flag so it's vertical.
|
||||
# The parsing is a bit awkward because different
|
||||
# versions of awk have limitations like "too many fields on line xyz". So we
|
||||
# use 'cut' to shorten the lines. We count all things into temporary variables
|
||||
# for each process in the processlist, and when we hit the Info: line which
|
||||
# ought to be the last line in the process, we decide what to do with the temp
|
||||
# variables. If we're summarizing Command, we count everything; otherwise, only
|
||||
# non-Sleep processes get counted towards the sum and max of Time.
|
||||
summarize_processlist () {
|
||||
local file="$1"
|
||||
for param in Command User Host db State; do
|
||||
@@ -1164,10 +1162,6 @@ summarize_processlist () {
|
||||
echo
|
||||
}
|
||||
|
||||
# Pretty-prints the my.cnf file. It's super annoying, but some *modern*
|
||||
# versions of awk don't support POSIX character sets in regular
|
||||
# expressions, like [[:space:]] (looking at you, Debian). So
|
||||
# the below patterns contain [<space><tab>] and must remain that way.
|
||||
pretty_print_cnf_file () {
|
||||
local file="$1"
|
||||
awk '
|
||||
@@ -1176,10 +1170,10 @@ pretty_print_cnf_file () {
|
||||
}
|
||||
/^ *[a-zA-Z[]/ {
|
||||
if (length($2)) {
|
||||
gsub(/^[ ]*/, "", $1);
|
||||
gsub(/^[ ]*/, "", $2);
|
||||
gsub(/[ ]*$/, "", $1);
|
||||
gsub(/[ ]*$/, "", $2);
|
||||
gsub(/^[ ]*/, "", $1);
|
||||
gsub(/^[ ]*/, "", $2);
|
||||
gsub(/[ ]*$/, "", $1);
|
||||
gsub(/[ ]*$/, "", $2);
|
||||
printf("%-35s = %s\n", $1, $2);
|
||||
}
|
||||
else if ( $0 ~ /\[/ ) {
|
||||
@@ -1325,7 +1319,6 @@ find_transation_states () {
|
||||
group_concat "${tmpfile}"
|
||||
}
|
||||
|
||||
# Summarizes various things about InnoDB status that are not easy to see by eye.
|
||||
format_innodb_status () {
|
||||
local file=$1
|
||||
name_val "Checkpoint Age" "$(shorten $(find_checkpoint_age "${file}") 0)"
|
||||
@@ -1361,19 +1354,12 @@ format_innodb_status () {
|
||||
fi
|
||||
}
|
||||
|
||||
# Summarizes per-database statistics for a bunch of different things: count of
|
||||
# tables, views, etc. $1 is the file name. $2 is the database name; if none,
|
||||
# then there should be multiple databases.
|
||||
format_overall_db_stats () {
|
||||
local file="$1"
|
||||
local tmpfile="$TMPDIR/format_overall_db_stats.tmp"
|
||||
echo
|
||||
# We keep counts of everything in an associative array keyed by db name, and
|
||||
# what it is. The num_dbs counter is to ensure sort order is consistent when
|
||||
# we run the awk commands following this one.
|
||||
awk '
|
||||
BEGIN {
|
||||
# In case there is no USE statement in the file.
|
||||
db = "{chosen}";
|
||||
num_dbs = 0;
|
||||
}
|
||||
@@ -1385,7 +1371,6 @@ format_overall_db_stats () {
|
||||
}
|
||||
}
|
||||
/^CREATE TABLE/ {
|
||||
# Handle single-DB dumps, where there is no USE statement.
|
||||
if (num_dbs == 0) {
|
||||
num_dbs = 1;
|
||||
db_seen[db] = 1;
|
||||
@@ -1430,10 +1415,8 @@ format_overall_db_stats () {
|
||||
tail -n +3 "$tmpfile" | sort
|
||||
|
||||
echo
|
||||
# Now do the summary of engines per DB
|
||||
awk '
|
||||
BEGIN {
|
||||
# In case there is no USE statement in the file.
|
||||
db = "{chosen}";
|
||||
num_dbs = 0;
|
||||
num_engines = 0;
|
||||
@@ -1446,7 +1429,6 @@ format_overall_db_stats () {
|
||||
}
|
||||
}
|
||||
/^\) ENGINE=/ {
|
||||
# Handle single-DB dumps, where there is no USE statement.
|
||||
if (num_dbs == 0) {
|
||||
num_dbs = 1;
|
||||
db_seen[db] = 1;
|
||||
@@ -1490,11 +1472,8 @@ format_overall_db_stats () {
|
||||
tail -n +2 "$tmpfile" | sort
|
||||
|
||||
echo
|
||||
# Now do the summary of index types per DB. Careful -- index is a reserved
|
||||
# word in awk.
|
||||
awk '
|
||||
BEGIN {
|
||||
# In case there is no USE statement in the file.
|
||||
db = "{chosen}";
|
||||
num_dbs = 0;
|
||||
num_idxes = 0;
|
||||
@@ -1507,7 +1486,6 @@ format_overall_db_stats () {
|
||||
}
|
||||
}
|
||||
/KEY/ {
|
||||
# Handle single-DB dumps, where there is no USE statement.
|
||||
if (num_dbs == 0) {
|
||||
num_dbs = 1;
|
||||
db_seen[db] = 1;
|
||||
@@ -1563,10 +1541,8 @@ format_overall_db_stats () {
|
||||
tail -n +2 "$tmpfile" | sort
|
||||
|
||||
echo
|
||||
# Now do the summary of datatypes per DB
|
||||
awk '
|
||||
BEGIN {
|
||||
# In case there is no USE statement in the file.
|
||||
db = "{chosen}";
|
||||
num_dbs = 0;
|
||||
num_types = 0;
|
||||
@@ -1579,7 +1555,6 @@ format_overall_db_stats () {
|
||||
}
|
||||
}
|
||||
/^ `/ {
|
||||
# Handle single-DB dumps, where there is no USE statement.
|
||||
if (num_dbs == 0) {
|
||||
num_dbs = 1;
|
||||
db_seen[db] = 1;
|
||||
@@ -1656,25 +1631,7 @@ format_overall_db_stats () {
|
||||
echo
|
||||
}
|
||||
|
||||
_myisam () {
|
||||
local variables_file="$1"
|
||||
local status_file="$2"
|
||||
|
||||
local buf_size=$(get_var key_buffer_size "$variables_file")
|
||||
local blk_size=$(get_var key_cache_block_size "$variables_file")
|
||||
local blk_unus=$(get_var Key_blocks_unused "$status_file")
|
||||
local blk_unfl=$(get_var Key_blocks_not_flushed "$variables_file")
|
||||
local unus=$((${blk_unus} * ${blk_size}))
|
||||
local unfl=$((${blk_unfl} * ${blk_size}))
|
||||
local used=$((${buf_size} - ${unus}))
|
||||
|
||||
name_val "Key Cache" "$(shorten ${buf_size} 1)"
|
||||
name_val "Pct Used" "$(fuzzy_pct ${used} ${buf_size})"
|
||||
name_val "Unflushed" "$(fuzzy_pct ${unfl} ${buf_size})"
|
||||
}
|
||||
|
||||
|
||||
_percona_server_features () {
|
||||
section_percona_server_features () {
|
||||
local file="$1"
|
||||
name_val "Table & Index Stats" \
|
||||
"$(feat_on "$file" userstat_running)"
|
||||
@@ -1702,12 +1659,27 @@ _percona_server_features () {
|
||||
"$(get_var "pt-summary-internal-FNV_64" "$file")"
|
||||
}
|
||||
|
||||
_innodb () {
|
||||
section_myisam () {
|
||||
local variables_file="$1"
|
||||
local status_file="$2"
|
||||
|
||||
local buf_size=$(get_var key_buffer_size "$variables_file")
|
||||
local blk_size=$(get_var key_cache_block_size "$variables_file")
|
||||
local blk_unus=$(get_var Key_blocks_unused "$status_file")
|
||||
local blk_unfl=$(get_var Key_blocks_not_flushed "$variables_file")
|
||||
local unus=$((${blk_unus} * ${blk_size}))
|
||||
local unfl=$((${blk_unfl} * ${blk_size}))
|
||||
local used=$((${buf_size} - ${unus}))
|
||||
|
||||
name_val "Key Cache" "$(shorten ${buf_size} 1)"
|
||||
name_val "Pct Used" "$(fuzzy_pct ${used} ${buf_size})"
|
||||
name_val "Unflushed" "$(fuzzy_pct ${unfl} ${buf_size})"
|
||||
}
|
||||
|
||||
section_innodb () {
|
||||
local variables_file="$1"
|
||||
local status_file="$2"
|
||||
|
||||
# XXX TODO I don't think this is working right.
|
||||
# XXX TODO Should it use data from information_schema.plugins too?
|
||||
local version=$(get_var innodb_version "$variables_file")
|
||||
name_val Version ${version:-default}
|
||||
|
||||
@@ -1728,7 +1700,7 @@ _innodb () {
|
||||
local log_file="$(get_var innodb_log_files_in_group "$variables_file")"
|
||||
local log_total=$(echo 1 | awk "{printf \"%.2f\n\", ${log_size}*${log_file}}" )
|
||||
name_val "Log File Size" \
|
||||
"${log_file} * $(shorten ${log_size} 1) = $(shorten ${log_total} 1 1000)"
|
||||
"${log_file} * $(shorten ${log_size} 1 1000) = $(shorten ${log_total} 1 1000)"
|
||||
name_val "Log Buffer Size" \
|
||||
"$(shorten $(get_var innodb_log_buffer_size "$variables_file") 0)"
|
||||
name_val "Flush Method" \
|
||||
@@ -1759,7 +1731,8 @@ _innodb () {
|
||||
"$(get_var innodb_adaptive_checkpoint "$variables_file")"
|
||||
}
|
||||
|
||||
_noteworthy_variables () {
|
||||
|
||||
section_noteworthy_variables () {
|
||||
local file="$1"
|
||||
|
||||
name_val "Auto-Inc Incr/Offset" "$(get_var auto_increment_increment "$file")/$(get_var auto_increment_offset "$file")"
|
||||
@@ -1826,9 +1799,6 @@ _semi_sync_stats_for () {
|
||||
fi
|
||||
}
|
||||
|
||||
# Make a pattern of things we want to omit because they aren't
|
||||
# counters, they are gauges (in RRDTool terminology). Gauges are shown
|
||||
# elsewhere in the output.
|
||||
noncounters_pattern () {
|
||||
local noncounters_pattern=""
|
||||
|
||||
@@ -1861,124 +1831,12 @@ noncounters_pattern () {
|
||||
echo $noncounters_pattern
|
||||
}
|
||||
|
||||
|
||||
# Uses mysqldump and dumps the results to FILE.
|
||||
# args and dbtodump are passed to mysqldump.
|
||||
get_mysqldump_for () {
|
||||
local file="$1"
|
||||
local args="$2"
|
||||
local dbtodump="${3:---all-databases}"
|
||||
|
||||
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
||||
--skip-add-locks --skip-add-drop-table --compact \
|
||||
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
||||
${args} "${dbtodump}" > "$file"
|
||||
}
|
||||
|
||||
# Returns a string with arguments to pass to mysqldump.
|
||||
# Takes one argument, which should be a
|
||||
get_mysqldump_args () {
|
||||
local file="$1"
|
||||
local trg_arg=""
|
||||
|
||||
# If mysqldump supports triggers, then add options for routines.
|
||||
if $CMD_MYSQLDUMP --help --verbose 2>&1 | grep triggers >/dev/null; then
|
||||
_d "mysqldump supports triggers"
|
||||
trg_arg="--routines"
|
||||
fi
|
||||
|
||||
if [ "${trg_arg}" ]; then
|
||||
# Find out if there are any triggers. If there are none, we will skip
|
||||
# that option to mysqldump, because when mysqldump checks for them, it
|
||||
# can take a long time, one table at a time.
|
||||
local triggers="--skip-triggers"
|
||||
local trg=$(get_var "pt-summary-internal-trigger_count" "$file" )
|
||||
if [ -n "${trg}" ] && [ "${trg}" -gt 0 ]; then
|
||||
_d "We have triggers to dump"
|
||||
triggers="--triggers"
|
||||
fi
|
||||
trg_arg="${trg_arg} ${triggers}";
|
||||
fi
|
||||
echo "${trg_arg}"
|
||||
}
|
||||
|
||||
check_mysql () {
|
||||
# Check that mysql and mysqldump are in PATH. If not, we're
|
||||
# already dead in the water, so don't bother with cmd line opts,
|
||||
# just error and exit.
|
||||
[ -n "$(mysql --help 2>/dev/null)" ] \
|
||||
|| die "Cannot execute mysql. Check that it is in PATH."
|
||||
[ -n "$(mysqldump --help 2>/dev/null)" ] \
|
||||
|| die "Cannot execute mysqldump. Check that it is in PATH."
|
||||
|
||||
# Now that we have the cmd line opts, check that we can actually
|
||||
# connect to MySQL.
|
||||
[ -n "$(mysql $EXT_ARGV -e 'SELECT 1')" ] \
|
||||
|| die "Cannot connect to MySQL. Check that MySQL is running and that the options after -- are correct."
|
||||
|
||||
}
|
||||
|
||||
sigtrap() {
|
||||
warn "Caught signal, forcing exit"
|
||||
exit $EXIT_STATUS
|
||||
}
|
||||
|
||||
# ##############################################################################
|
||||
# The main() function is called at the end of the script. This makes it
|
||||
# testable. Major bits of parsing are separated into functions for testability.
|
||||
# ##############################################################################
|
||||
main() {
|
||||
# Prepending SIG to these doesn't work with NetBSD's sh
|
||||
trap sigtrap HUP INT TERM
|
||||
|
||||
local RAN_WITH="--sleep=$OPT_SLEEP --dump-schemas=$OPT_DUMP_SCHEMAS --save-data=$OPT_SAVE_DATA"
|
||||
|
||||
_d "Starting $0 $RAN_WITH"
|
||||
|
||||
# Begin by setting the $PATH to include some common locations that are not
|
||||
# always in the $PATH, including the "sbin" locations. On SunOS systems,
|
||||
# prefix the path with the location of more sophisticated utilities.
|
||||
export PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/libexec"
|
||||
export PATH="${PATH}:/usr/mysql/bin/:/usr/local/sbin:/usr/sbin:/sbin"
|
||||
export PATH="/usr/gnu/bin/:/usr/xpg4/bin/:${PATH}"
|
||||
|
||||
_d "Going to use: mysql=${CMD_MYSQL} mysqldump=${CMD_MYSQLDUMP}"
|
||||
|
||||
# Create the tmpdir for everything to run in
|
||||
mk_tmpdir
|
||||
|
||||
# Set DATA_DIR where we'll save collected data files.
|
||||
local data_dir="$(setup_data_dir)"
|
||||
|
||||
_d "Temp dir is [$TMPDIR], saving data in [$data_dir]"
|
||||
|
||||
# ########################################################################
|
||||
# Fetch most info, leave a child in the background gathering the rest
|
||||
# ########################################################################
|
||||
collect_mysql_info "${data_dir}"
|
||||
|
||||
# ########################################################################
|
||||
# Format and pretty-print the data
|
||||
# ########################################################################
|
||||
report_summary "${data_dir}"
|
||||
|
||||
rm_tmpdir
|
||||
|
||||
}
|
||||
|
||||
report_summary () {
|
||||
report_mysql_summary () {
|
||||
local dir="$1"
|
||||
local prefix="${2:-percona-toolkit}"
|
||||
|
||||
# Make sure the MYSQL_etc_FILE variables are set
|
||||
setup_files "$dir"
|
||||
|
||||
# Field width for name_val
|
||||
local NAME_VAL_LEN=25
|
||||
|
||||
# ########################################################################
|
||||
# Header for the whole thing, table of discovered instances
|
||||
# ########################################################################
|
||||
|
||||
section Percona_Toolkit_MySQL_Summary_Report
|
||||
name_val "System time" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)"
|
||||
@@ -1988,9 +1846,6 @@ report_summary () {
|
||||
section MySQL_Executable
|
||||
name_val "Has symbols" "$( get_var "pt-summary-internal-symbols" "$dir/${prefix}-mysql-variables" )"
|
||||
|
||||
# ########################################################################
|
||||
# General date, hostname, etc
|
||||
# ########################################################################
|
||||
local user="$(get_var "pt-summary-internal-user" "$dir/${prefix}-mysql-variables")"
|
||||
local port="$(get_var port "$dir/${prefix}-mysql-variables")"
|
||||
local now="$(get_var "pt-summary-internal-NOW" "$dir/${prefix}-mysql-variables")"
|
||||
@@ -2018,8 +1873,6 @@ report_summary () {
|
||||
name_val Replication "Is ${slave}a slave, has ${slavecount} slaves connected"
|
||||
|
||||
|
||||
# TODO move this into a section with other files: error log, slow log and
|
||||
# show the sizes
|
||||
local pid_file="$(get_var pid_file "$dir/${prefix}-mysql-variables")"
|
||||
local PID_EXISTS=""
|
||||
if [ -e "${pid_file}" ]; then
|
||||
@@ -2029,45 +1882,26 @@ report_summary () {
|
||||
fi
|
||||
name_val Pidfile "${pid_file} ${PID_EXISTS}"
|
||||
|
||||
# ########################################################################
|
||||
# Processlist, sliced several different ways
|
||||
# ########################################################################
|
||||
section Processlist
|
||||
summarize_processlist "$dir/${prefix}-mysql-processlist"
|
||||
|
||||
# ########################################################################
|
||||
# Queries and query plans
|
||||
# ########################################################################
|
||||
section "Status_Counters_(Wait_${OPT_SLEEP}_Seconds)"
|
||||
# Wait for the child that was forked during collection.
|
||||
wait
|
||||
local noncounters_pattern="$(noncounters_pattern)"
|
||||
format_status_variables "$dir/${prefix}-mysql-status-defer" | grep -v "${noncounters_pattern}"
|
||||
|
||||
# ########################################################################
|
||||
# Table cache
|
||||
# ########################################################################
|
||||
section Table_cache
|
||||
local open_tables=$(get_var Open_tables "$dir/${prefix}-mysql-status")
|
||||
local table_cache=$(get_table_cache "$dir/${prefix}-mysql-status")
|
||||
name_val Size $table_cache
|
||||
name_val Usage "$(fuzzy_pct ${open_tables} ${table_cache})"
|
||||
|
||||
# ########################################################################
|
||||
# Percona Server features
|
||||
# ########################################################################
|
||||
section Key_Percona_Server_features
|
||||
_percona_server_features "$dir/${prefix}-mysql-variables"
|
||||
section_percona_server_features "$dir/${prefix}-mysql-variables"
|
||||
|
||||
# ########################################################################
|
||||
# Plugins
|
||||
# ########################################################################
|
||||
section Plugins
|
||||
name_val "InnoDB compression" "$(get_plugin_status "$dir/${prefix}-mysql-plugins" "INNODB_CMP")"
|
||||
|
||||
# ########################################################################
|
||||
# Query cache
|
||||
# ########################################################################
|
||||
if [ "$(get_var have_query_cache "$dir/${prefix}-mysql-variables")" ]; then
|
||||
section Query_cache
|
||||
local query_cache_size=$(get_var query_cache_size "$dir/${prefix}-mysql-variables")
|
||||
@@ -2095,14 +1929,8 @@ report_summary () {
|
||||
fi
|
||||
fi
|
||||
|
||||
# ########################################################################
|
||||
# Schema, databases, data type, other analysis.
|
||||
# ########################################################################
|
||||
section Schema
|
||||
# Assume "no" if stdin or stdout is not a terminal, so this can be run and
|
||||
# put into a file, or piped into a pager, or something else like that.
|
||||
local reply="n"
|
||||
# But dump no matter what if they passed in something through --dump-schemas
|
||||
if [ -n "${OPT_DUMP_SCHEMAS}" ]; then
|
||||
reply="y"
|
||||
elif [ -t 0 -a -t 1 ]; then
|
||||
@@ -2112,9 +1940,7 @@ report_summary () {
|
||||
fi
|
||||
if echo "${reply:-n}" | grep -i '^y' > /dev/null ; then
|
||||
if [ -z "${OPT_DUMP_SCHEMAS}" ]; then
|
||||
# If --dump-schemas wasn't used, ask what they want
|
||||
|
||||
# Find out which databases to dump
|
||||
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. "
|
||||
local dbtodump=""
|
||||
@@ -2123,9 +1949,6 @@ report_summary () {
|
||||
get_mysqldump_for "$dir/${prefix}-mysqldump" "${trg_arg}" "${dbtodump}"
|
||||
fi
|
||||
|
||||
# Test the result by checking the file, not by the exit status, because we
|
||||
# might get partway through and then die, and the info is worth analyzing
|
||||
# anyway.
|
||||
|
||||
if [ -e "$dir/${prefix}-mysqldump" -a -s "$dir/${prefix}-mysqldump" ] \
|
||||
&& grep 'CREATE TABLE' "$dir/${prefix}-mysqldump" >/dev/null 2>&1; then
|
||||
@@ -2137,9 +1960,6 @@ report_summary () {
|
||||
echo "Skipping schema analysis"
|
||||
fi
|
||||
|
||||
# ########################################################################
|
||||
# Noteworthy Technologies
|
||||
# ########################################################################
|
||||
section Noteworthy_Technologies
|
||||
if [ -s "$dir/${prefix}-mysqldump" ]; then
|
||||
if grep FULLTEXT "$dir/${prefix}-mysqldump" > /dev/null; then
|
||||
@@ -2199,37 +2019,24 @@ report_summary () {
|
||||
name_val "Prepared statement count" "${prep_count}"
|
||||
fi
|
||||
|
||||
# ########################################################################
|
||||
# InnoDB
|
||||
# ########################################################################
|
||||
section InnoDB
|
||||
local have_innodb=$(get_var have_innodb "$dir/${prefix}-mysql-variables")
|
||||
if [ "${have_innodb}" = "YES" ]; then
|
||||
_innodb "$dir/${prefix}-mysql-variables" "$dir/${prefix}-mysql-status"
|
||||
section_innodb "$dir/${prefix}-mysql-variables" "$dir/${prefix}-mysql-status"
|
||||
|
||||
if [ -s "$dir/${prefix}-innodb-status" ]; then
|
||||
format_innodb_status "$dir/${prefix}-innodb-status"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ########################################################################
|
||||
# MyISAM
|
||||
# ########################################################################
|
||||
section MyISAM
|
||||
_myisam "$dir/${prefix}-mysql-variables" "$dir/${prefix}-mysql-status"
|
||||
section_myisam "$dir/${prefix}-mysql-variables" "$dir/${prefix}-mysql-status"
|
||||
|
||||
# ########################################################################
|
||||
# Users & Security
|
||||
# ########################################################################
|
||||
section Security
|
||||
local users="$( format_users "$dir/${prefix}-mysql-users" )"
|
||||
# XXX TODO Give it a different formatting?
|
||||
name_val Users "${users}"
|
||||
name_val "Old Passwords" "$(get_var old_passwords "$dir/${prefix}-mysql-variables")"
|
||||
|
||||
# ########################################################################
|
||||
# Binary Logging
|
||||
# ########################################################################
|
||||
section Binary_Logging
|
||||
|
||||
if [ -s "$dir/${prefix}-mysql-master-logs" ] \
|
||||
@@ -2243,18 +2050,10 @@ report_summary () {
|
||||
format_binlog_filters "$dir/${prefix}-mysql-master-status"
|
||||
fi
|
||||
|
||||
# Replication: seconds behind, running, filters, skip_slave_start, skip_errors,
|
||||
# read_only, temp tables open, slave_net_timeout, slave_exec_mode
|
||||
|
||||
# ########################################################################
|
||||
# Interesting things that you just ought to know about.
|
||||
# ########################################################################
|
||||
section Noteworthy_Variables
|
||||
_noteworthy_variables "$dir/${prefix}-mysql-variables"
|
||||
section_noteworthy_variables "$dir/${prefix}-mysql-variables"
|
||||
|
||||
# ########################################################################
|
||||
# If there is a my.cnf in a standard location, see if we can pretty-print it.
|
||||
# ########################################################################
|
||||
section Configuration_File
|
||||
local cnf_file="$(get_var "pt-summary-internal-Config_File" "$dir/${prefix}-mysql-variables")"
|
||||
if [ -n "${cnf_file}" ]; then
|
||||
@@ -2264,10 +2063,87 @@ report_summary () {
|
||||
name_val "Config File" "Cannot autodetect or find, giving up"
|
||||
fi
|
||||
|
||||
# Make sure that we signal the end of the tool's output.
|
||||
section The_End
|
||||
}
|
||||
|
||||
# ###########################################################################
|
||||
# End report_mysql_info package
|
||||
# ###########################################################################
|
||||
|
||||
# ########################################################################
|
||||
# Some global setup is necessary for cross-platform compatibility, even
|
||||
# when sourcing this script for testing purposes.
|
||||
# ########################################################################
|
||||
|
||||
TOOL="pt-mysql-summary"
|
||||
|
||||
CMD_MYSQL="$(_which mysql)"
|
||||
CMD_MYSQLDUMP="$( _which mysqldump )"
|
||||
|
||||
check_mysql () {
|
||||
# Check that mysql and mysqldump are in PATH. If not, we're
|
||||
# already dead in the water, so don't bother with cmd line opts,
|
||||
# just error and exit.
|
||||
[ -n "$(mysql --help 2>/dev/null)" ] \
|
||||
|| die "Cannot execute mysql. Check that it is in PATH."
|
||||
[ -n "$(mysqldump --help 2>/dev/null)" ] \
|
||||
|| die "Cannot execute mysqldump. Check that it is in PATH."
|
||||
|
||||
# Now that we have the cmd line opts, check that we can actually
|
||||
# connect to MySQL.
|
||||
[ -n "$(mysql $EXT_ARGV -e 'SELECT 1')" ] \
|
||||
|| die "Cannot connect to MySQL. Check that MySQL is running and that the options after -- are correct."
|
||||
|
||||
}
|
||||
|
||||
sigtrap() {
|
||||
warn "Caught signal, forcing exit"
|
||||
exit $EXIT_STATUS
|
||||
}
|
||||
|
||||
# ##############################################################################
|
||||
# The main() function is called at the end of the script. This makes it
|
||||
# testable. Major bits of parsing are separated into functions for testability.
|
||||
# ##############################################################################
|
||||
main() {
|
||||
# Prepending SIG to these doesn't work with NetBSD's sh
|
||||
trap sigtrap HUP INT TERM
|
||||
|
||||
local RAN_WITH="--sleep=$OPT_SLEEP --dump-schemas=$OPT_DUMP_SCHEMAS --save-data=$OPT_SAVE_DATA"
|
||||
|
||||
_d "Starting $0 $RAN_WITH"
|
||||
|
||||
# Begin by setting the $PATH to include some common locations that are not
|
||||
# always in the $PATH, including the "sbin" locations. On SunOS systems,
|
||||
# prefix the path with the location of more sophisticated utilities.
|
||||
export PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/libexec"
|
||||
export PATH="${PATH}:/usr/mysql/bin/:/usr/local/sbin:/usr/sbin:/sbin"
|
||||
export PATH="/usr/gnu/bin/:/usr/xpg4/bin/:${PATH}"
|
||||
|
||||
_d "Going to use: mysql=${CMD_MYSQL} mysqldump=${CMD_MYSQLDUMP}"
|
||||
|
||||
# Create the tmpdir for everything to run in
|
||||
mk_tmpdir
|
||||
|
||||
# Set DATA_DIR where we'll save collected data files.
|
||||
local data_dir="$(setup_data_dir)"
|
||||
|
||||
_d "Temp dir is [$TMPDIR], saving data in [$data_dir]"
|
||||
|
||||
# ########################################################################
|
||||
# Fetch most info, leave a child in the background gathering the rest
|
||||
# ########################################################################
|
||||
collect_mysql_info "${data_dir}"
|
||||
|
||||
# ########################################################################
|
||||
# Format and pretty-print the data
|
||||
# ########################################################################
|
||||
report_mysql_summary "${data_dir}"
|
||||
|
||||
rm_tmpdir
|
||||
|
||||
}
|
||||
|
||||
# Execute the program if it was not included from another file.
|
||||
# This makes it possible to include without executing, and thus test.
|
||||
if [ "${0##*/}" = "$TOOL" ] \
|
||||
|
@@ -140,9 +140,49 @@ collect_internal_vars () {
|
||||
echo "pt-summary-internal-symbols $has_symbols" >> "$file"
|
||||
}
|
||||
|
||||
# Uses mysqldump and dumps the results to FILE.
|
||||
# args and dbtodump are passed to mysqldump.
|
||||
get_mysqldump_for () {
|
||||
local file="$1"
|
||||
local args="$2"
|
||||
local dbtodump="${3:---all-databases}"
|
||||
|
||||
$CMD_MYSQLDUMP $EXT_ARGV --no-data --skip-comments \
|
||||
--skip-add-locks --skip-add-drop-table --compact \
|
||||
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
|
||||
${args} "${dbtodump}" > "$file"
|
||||
}
|
||||
|
||||
# Returns a string with arguments to pass to mysqldump.
|
||||
# Takes one argument, which should be a
|
||||
get_mysqldump_args () {
|
||||
local file="$1"
|
||||
local trg_arg=""
|
||||
|
||||
# If mysqldump supports triggers, then add options for routines.
|
||||
if $CMD_MYSQLDUMP --help --verbose 2>&1 | grep triggers >/dev/null; then
|
||||
_d "mysqldump supports triggers"
|
||||
trg_arg="--routines"
|
||||
fi
|
||||
|
||||
if [ "${trg_arg}" ]; then
|
||||
# Find out if there are any triggers. If there are none, we will skip
|
||||
# that option to mysqldump, because when mysqldump checks for them, it
|
||||
# can take a long time, one table at a time.
|
||||
local triggers="--skip-triggers"
|
||||
local trg=$(get_var "pt-summary-internal-trigger_count" "$file" )
|
||||
if [ -n "${trg}" ] && [ "${trg}" -gt 0 ]; then
|
||||
_d "We have triggers to dump"
|
||||
triggers="--triggers"
|
||||
fi
|
||||
trg_arg="${trg_arg} ${triggers}";
|
||||
fi
|
||||
echo "${trg_arg}"
|
||||
}
|
||||
|
||||
collect_mysql_info () {
|
||||
local dir="$1"
|
||||
local prefix="$2"
|
||||
local prefix="${2:-percona-toolkit}"
|
||||
|
||||
collect_mysqld_instances "$dir/${prefix}-mysqld-instances"
|
||||
|
||||
|
@@ -51,7 +51,6 @@ fuzzy_formula='
|
||||
# Does fuzzy rounding: rounds to nearest interval, but the interval gets larger
|
||||
# as the number gets larger. This is to make things easier to diff.
|
||||
fuzz () {
|
||||
_d "fuzz: $1"
|
||||
echo $1 | awk "{fuzzy_var=\$1; ${fuzzy_formula} print fuzzy_var;}"
|
||||
}
|
||||
|
||||
|
1291
lib/bash/report_mysql_info.sh
Normal file
1291
lib/bash/report_mysql_info.sh
Normal file
File diff suppressed because it is too large
Load Diff
1
t/lib/bash/collect_mysql_info.t
Symbolic link
1
t/lib/bash/collect_mysql_info.t
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../util/test-bash-functions
|
@@ -85,6 +85,11 @@ is \
|
||||
"A | B" \
|
||||
"name_val and NAME_VAL_LEN work"
|
||||
|
||||
# fuzz
|
||||
|
||||
is $(fuzz 11) "10" "fuzz 11"
|
||||
is $(fuzz 49) "50" "fuzz 49"
|
||||
|
||||
# ###########################################################################
|
||||
# Done
|
||||
# ###########################################################################
|
||||
|
1
t/lib/bash/report_formatting.t
Symbolic link
1
t/lib/bash/report_formatting.t
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../util/test-bash-functions
|
711
t/lib/bash/report_mysql_info.sh
Normal file
711
t/lib/bash/report_mysql_info.sh
Normal file
@@ -0,0 +1,711 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
plan 29
|
||||
|
||||
. "$LIB_DIR/alt_cmds.sh"
|
||||
. "$LIB_DIR/log_warn_die.sh"
|
||||
. "$LIB_DIR/summary_common.sh"
|
||||
. "$LIB_DIR/report_formatting.sh"
|
||||
. "$LIB_DIR/report_mysql_info.sh"
|
||||
|
||||
TMPDIR="$TEST_TMPDIR"
|
||||
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
|
||||
TOOL="pt-mysql-summary"
|
||||
|
||||
samples="$PERCONA_TOOLKIT_BRANCH/t/pt-mysql-summary/samples"
|
||||
NAME_VAL_LEN=20
|
||||
# ###########################################################################
|
||||
# table_cache
|
||||
# ###########################################################################
|
||||
|
||||
rm $TMPDIR/table_cache_tests 2>/dev/null
|
||||
touch $TMPDIR/table_cache_tests
|
||||
|
||||
is \
|
||||
$(get_table_cache "$TMPDIR/table_cache_tests") \
|
||||
0 \
|
||||
"0 if neither table_cache nor table_open_cache are present"
|
||||
|
||||
cat <<EOF > $TMPDIR/table_cache_tests
|
||||
table_cache 5
|
||||
table_open_cache 4
|
||||
EOF
|
||||
|
||||
is \
|
||||
$(get_table_cache "$TMPDIR/table_cache_tests") \
|
||||
4 \
|
||||
"If there's a table_open_cache present, uses that"
|
||||
|
||||
cat <<EOF > $TMPDIR/table_cache_tests
|
||||
table_cache 5
|
||||
EOF
|
||||
|
||||
is \
|
||||
$(get_table_cache "$TMPDIR/table_cache_tests") \
|
||||
5 \
|
||||
"Otherwise, defaults to table_cache"
|
||||
|
||||
# ###########################################################################
|
||||
# summarize_processlist
|
||||
# ###########################################################################
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
Command COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
Binlog Dump 1 1 9000000 9000000
|
||||
Connect 2 2 6000000 5000000
|
||||
Query 2 2 0 0
|
||||
Sleep 150 0 150000 20000
|
||||
|
||||
User COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
acjcxx 4 0 0 0
|
||||
aecac 1 0 0 0
|
||||
babeecc 20 0 0 0
|
||||
centous 2 0 0 0
|
||||
crcpcpc 2 0 0 0
|
||||
crgcp4c 3 0 0 0
|
||||
eanecj 30 1 0 0
|
||||
ebace 10 0 0 0
|
||||
etace 80 0 0 0
|
||||
goate 8 0 0 0
|
||||
qjveec 1 0 0 0
|
||||
repl 1 1 9000000 9000000
|
||||
root 1 1 0 0
|
||||
system user 2 2 6000000 5000000
|
||||
|
||||
Host COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
10.14.82.196 6 0 0 0
|
||||
10.14.82.202 20 0 0 0
|
||||
10.17.85.100 9 0 0 0
|
||||
10.17.85.74 1 1 9000000 9000000
|
||||
10.17.85.86 35 0 0 0
|
||||
10.17.85.88 5 0 0 0
|
||||
10.17.85.90 10 0 0 0
|
||||
10.36.34.66 35 1 0 0
|
||||
2 2 6000000 5000000
|
||||
localhost 1 1 0 0
|
||||
someserver.woozle.com11 1 0 0 0
|
||||
someserver.woozle.com14 1 0 0 0
|
||||
someserver.woozle.com 40 0 0 0
|
||||
|
||||
db COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
aetecjc 175 1 0 0
|
||||
NULL 4 4 15000000 9000000
|
||||
|
||||
State COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
150 0 0 0
|
||||
Has read all relay log; waitin 1 1 300000 300000
|
||||
Has sent all binlog to slave; 1 1 9000000 9000000
|
||||
NULL 2 2 0 0
|
||||
Waiting for master to send eve 1 1 5000000 5000000
|
||||
|
||||
EOF
|
||||
|
||||
summarize_processlist "$samples/processlist-001.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "summarize_processlist"
|
||||
|
||||
|
||||
# ###########################################################################
|
||||
# summarize_binlogs
|
||||
# ###########################################################################
|
||||
NAME_VAL_LEN=25
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Binlogs | 20
|
||||
Zero-Sized | 3
|
||||
Total Size | 6.5G
|
||||
EOF
|
||||
|
||||
summarize_binlogs "$samples/mysql-master-logs-001.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/expected" "$TMPDIR/got" "summarize_binlogs"
|
||||
|
||||
# ###########################################################################
|
||||
# Reporting semisync replication
|
||||
# ###########################################################################
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
master semisync status | 0
|
||||
master trace level | 32, net wait (more information about network waits)
|
||||
master timeout in milliseconds | 10000
|
||||
master waits for slaves | ON
|
||||
master clients | 0
|
||||
master net_avg_wait_time | 0
|
||||
master net_wait_time | 0
|
||||
master net_waits | 0
|
||||
master no_times | 0
|
||||
master no_tx | 0
|
||||
master timefunc_failures | 0
|
||||
master tx_avg_wait_time | 0
|
||||
master tx_wait_time | 0
|
||||
master tx_waits | 0
|
||||
master wait_pos_backtraverse | 0
|
||||
master wait_sessions | 0
|
||||
master yes_tx | 0
|
||||
EOF
|
||||
|
||||
_semi_sync_stats_for "master" "$samples/mysql-variables-with-semisync.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/expected" "$TMPDIR/got" "semisync replication"
|
||||
|
||||
# ###########################################################################
|
||||
# pretty_print_cnf_file
|
||||
# ###########################################################################
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
[mysqld]
|
||||
datadir = /mnt/data/mysql
|
||||
socket = /mnt/data/mysql/mysql.sock
|
||||
old_passwords = 1
|
||||
ssl-key = /opt/mysql.pdns/.cert/server-key.pem
|
||||
ssl-cert = /opt/mysql.pdns/.cert/server-cert.pem
|
||||
ssl-ca = /opt/mysql.pdns/.cert/ca-cert.pem
|
||||
innodb_buffer_pool_size = 16M
|
||||
innodb_flush_method = O_DIRECT
|
||||
innodb_log_file_size = 64M
|
||||
innodb_log_buffer_size = 1M
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_file_per_table = 1
|
||||
ssl = 1
|
||||
server-id = 1
|
||||
log-bin = sl1-bin
|
||||
|
||||
[mysql.server]
|
||||
user = mysql
|
||||
basedir = /mnt/data
|
||||
|
||||
[mysqld_safe]
|
||||
log-error = /var/log/mysqld.log
|
||||
pid-file = /var/run/mysqld/mysqld.pid
|
||||
|
||||
[mysql]
|
||||
|
||||
[xtrabackup]
|
||||
target-dir = /data/backup
|
||||
EOF
|
||||
|
||||
pretty_print_cnf_file "$samples/my.cnf-001.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "pretty_print_cnf_file"
|
||||
|
||||
|
||||
# TODO BUG NUMBER#
|
||||
cp "$samples/my.cnf-001.txt" "$TMPDIR/test_pretty_print_cnf_file"
|
||||
echo "some_var_yadda=0" >> "$TMPDIR/test_pretty_print_cnf_file"
|
||||
echo "some_var_yadda = 0" >> "$TMPDIR/expected"
|
||||
|
||||
pretty_print_cnf_file "$TMPDIR/test_pretty_print_cnf_file" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "pretty_print_cnf_file, bug XXXXXX"
|
||||
|
||||
|
||||
# ###########################################################################
|
||||
# plugin_status
|
||||
# ###########################################################################
|
||||
|
||||
cat <<EOF > $TMPDIR/plugins
|
||||
binlog ACTIVE STORAGE ENGINE NULL GPL
|
||||
partition ACTIVE STORAGE ENGINE NULL GPL
|
||||
ARCHIVE ACTIVE STORAGE ENGINE NULL GPL
|
||||
BLACKHOLE ACTIVE STORAGE ENGINE NULL GPL
|
||||
CSV ACTIVE STORAGE ENGINE NULL GPL
|
||||
FEDERATED DISABLED STORAGE ENGINE NULL GPL
|
||||
MEMORY ACTIVE STORAGE ENGINE NULL GPL
|
||||
InnoDB ACTIVE STORAGE ENGINE NULL GPL
|
||||
MyISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
MRG_MYISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
EOF
|
||||
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins InnoDB )" \
|
||||
"ACTIVE" \
|
||||
"Sanity test, finds InnoDB as active"
|
||||
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins some_plugin_that_doesnt_exist )" \
|
||||
"Not found" \
|
||||
"Doesn't find a nonexistent plugin"
|
||||
|
||||
echo "INNODB_CMP ACTIVE" >> $TMPDIR/plugins
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins "INNODB_CMP" )" \
|
||||
"ACTIVE"
|
||||
|
||||
cat <<EOF > $TMPDIR/plugins
|
||||
binlog ACTIVE STORAGE ENGINE NULL GPL
|
||||
mysql_native_password ACTIVE AUTHENTICATION NULL GPL
|
||||
mysql_old_password ACTIVE AUTHENTICATION NULL GPL
|
||||
MRG_MYISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
MyISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
CSV ACTIVE STORAGE ENGINE NULL GPL
|
||||
MEMORY ACTIVE STORAGE ENGINE NULL GPL
|
||||
FEDERATED DISABLED STORAGE ENGINE NULL GPL
|
||||
ARCHIVE ACTIVE STORAGE ENGINE NULL GPL
|
||||
BLACKHOLE ACTIVE STORAGE ENGINE NULL GPL
|
||||
InnoDB ACTIVE STORAGE ENGINE NULL GPL
|
||||
INNODB_TRX ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_LOCKS ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_LOCK_WAITS ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMP ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMP_RESET ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMPMEM ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMPMEM_RESET ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
PERFORMANCE_SCHEMA ACTIVE STORAGE ENGINE NULL GPL
|
||||
partition ACTIVE STORAGE ENGINE NULL GPL
|
||||
EOF
|
||||
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins "INNODB_CMP" )" \
|
||||
"ACTIVE" \
|
||||
"Doesn't get confused by multiple plugins with the same prefix"
|
||||
|
||||
# ###########################################################################
|
||||
# parse_mysqld_instances
|
||||
# ###########################################################################
|
||||
|
||||
_NO_FALSE_NEGATIVES=1
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
3306 /var/lib/mysql ? ? /var/run/mysqld/mysqld.sock
|
||||
12345 /tmp/12345/data ? ? /tmp/12345/mysql_sandbox12345.sock
|
||||
12346 /tmp/12346/data ? ? /tmp/12346/mysql_sandbox12346.sock
|
||||
EOF
|
||||
parse_mysqld_instances "$samples/ps-mysqld-001.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "ps-mysqld-001.txt"
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
/var/lib/mysql ? ? /var/lib/mysql/mysql.sock
|
||||
EOF
|
||||
parse_mysqld_instances "$samples/ps-mysqld-002.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "ps-mysqld-002.txt"
|
||||
|
||||
#parse_mysqld_instances
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
3306 /mnt/data-store/mysql/data ? ? /tmp/mysql.sock
|
||||
EOF
|
||||
parse_mysqld_instances "$samples/ps-mysqld-003.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "ps-mysqld-003.txt"
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
/var/db/mysql ? ?
|
||||
EOF
|
||||
|
||||
cat <<EOF > "$TMPDIR/in"
|
||||
mysql 767 0.0 0.9 3492 1100 v0 I 3:01PM 0:00.07 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/db/mysql/freebsd.hsd1.va.comcast.net..pid
|
||||
mysql 818 0.0 17.4 45292 20584 v0 I 3:01PM 0:02.28 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --user=mysql --log-error=/var/db/mysql/freebsd.hsd1.va.comcast.net..err --pid-file=/var/db/mysql/freebsd.hsd1.va.comcast.net..pid
|
||||
EOF
|
||||
parse_mysqld_instances "$TMPDIR/in" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected"
|
||||
|
||||
# ###########################################################################
|
||||
# get_mysql_*
|
||||
# ###########################################################################
|
||||
NAME_VAL_LEN=20
|
||||
|
||||
cp $samples/mysql-variables-001.txt $TMPDIR/percona-toolkit-mysql-variables
|
||||
is \
|
||||
$(get_mysql_timezone "$TMPDIR/percona-toolkit-mysql-variables") \
|
||||
"EDT" \
|
||||
"get_mysql_timezone"
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
2010-05-27 11:38 (up 0+02:08:52)
|
||||
EOF
|
||||
cp $samples/mysql-status-001.txt $TMPDIR/percona-toolkit-mysql-status
|
||||
uptime="$(get_var Uptime $TMPDIR/percona-toolkit-mysql-status)"
|
||||
current_time="$(echo -e "2010-05-27 11:38\n")"
|
||||
get_mysql_uptime "${uptime}" "${current_time}" > $TMPDIR/got
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "get_mysql_uptime"
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Version | 5.0.51a-24+lenny2 (Debian)
|
||||
Built On | debian-linux-gnu i486
|
||||
EOF
|
||||
cp "$samples/mysql-variables-001.txt" "$TMPDIR/percona-toolkit-mysql-variables"
|
||||
get_mysql_version "$TMPDIR/percona-toolkit-mysql-variables" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "get_mysql_version"
|
||||
|
||||
# ###########################################################################
|
||||
# format_status_variables
|
||||
# ###########################################################################
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Variable Per day Per second 5 secs
|
||||
Bytes_received 8000000 100
|
||||
Bytes_sent 35000000 400
|
||||
Com_admin_commands 20
|
||||
Com_change_db 1000
|
||||
Com_delete 8000
|
||||
Com_insert 8000
|
||||
Com_lock_tables 200
|
||||
Com_replace 1250
|
||||
Com_select 22500
|
||||
Com_set_option 22500
|
||||
Com_show_binlogs 10
|
||||
Com_show_create_db 400
|
||||
Com_show_create_table 7000
|
||||
Com_show_databases 125
|
||||
Com_show_fields 7000
|
||||
Com_show_innodb_status 300
|
||||
Com_show_open_tables 10
|
||||
Com_show_processlist 300
|
||||
Com_show_slave_status 300
|
||||
Com_show_status 350
|
||||
Com_show_storage_engines 10
|
||||
Com_show_tables 400
|
||||
Com_show_triggers 7000
|
||||
Com_show_variables 450
|
||||
Com_truncate 300
|
||||
Com_unlock_tables 250
|
||||
Com_update 900
|
||||
Connections 2500
|
||||
Created_tmp_disk_tables 15000
|
||||
Created_tmp_files 60
|
||||
Created_tmp_tables 22500
|
||||
Flush_commands 10
|
||||
Handler_delete 8000
|
||||
Handler_read_first 2250
|
||||
Handler_read_key 30000
|
||||
Handler_read_next 15000
|
||||
Handler_read_rnd 9000
|
||||
Handler_read_rnd_next 300000 3
|
||||
Handler_update 17500
|
||||
Handler_write 250000 2
|
||||
Innodb_buffer_pool_pages_data 225
|
||||
Innodb_buffer_pool_pages_free 5000
|
||||
Innodb_buffer_pool_pages_total 6000
|
||||
Innodb_buffer_pool_read_ahead_rnd 10
|
||||
Innodb_buffer_pool_read_requests 2250
|
||||
Innodb_buffer_pool_reads 150
|
||||
Innodb_data_fsyncs 35
|
||||
Innodb_data_read 30000000 350
|
||||
Innodb_data_reads 300
|
||||
Innodb_data_writes 35
|
||||
Innodb_data_written 17500
|
||||
Innodb_log_writes 10
|
||||
Innodb_os_log_fsyncs 35
|
||||
Innodb_os_log_written 6000
|
||||
Innodb_page_size 175000 2
|
||||
Innodb_pages_read 225
|
||||
Key_blocks_unused 150000 1
|
||||
Key_blocks_used 175
|
||||
Key_read_requests 100000 1
|
||||
Key_reads 600
|
||||
Key_write_requests 70000
|
||||
Key_writes 17500
|
||||
Max_used_connections 45
|
||||
Open_files 1500
|
||||
Open_tables 700
|
||||
Opened_tables 15000
|
||||
Qcache_free_blocks 80
|
||||
Qcache_free_memory 175000000 2250
|
||||
Qcache_hits 8000
|
||||
Qcache_inserts 20000
|
||||
Qcache_not_cached 10000
|
||||
Qcache_queries_in_cache 225
|
||||
Qcache_total_blocks 600
|
||||
Questions 100000 1
|
||||
Select_scan 25000
|
||||
Sort_rows 8000
|
||||
Sort_scan 300
|
||||
Table_locks_immediate 50000 17500
|
||||
Table_locks_waited 10 1
|
||||
Threads_cached 35
|
||||
Threads_connected 10
|
||||
Threads_created 45
|
||||
Threads_running 10
|
||||
Uptime 90000 1 1
|
||||
Uptime_since_flush_status 90000 1
|
||||
EOF
|
||||
|
||||
join $samples/mysql-status-00{1,2}.txt > "$TMPDIR/in"
|
||||
format_status_variables "$TMPDIR/in" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "format_status_variables"
|
||||
|
||||
# ###########################################################################
|
||||
# format_overall_db_stats
|
||||
# ###########################################################################
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
Database Tables Views SPs Trigs Funcs FKs Partn
|
||||
mysql 17
|
||||
sakila 17 7 3 6 3 22 1
|
||||
|
||||
Database MyISAM InnoDB
|
||||
mysql 17
|
||||
sakila 2 15
|
||||
|
||||
Database BTREE FULLTEXT
|
||||
mysql 24
|
||||
sakila 63 1
|
||||
|
||||
c t s e t s i t b l b v d y d m
|
||||
h i e n i m n e l o i a a e e e
|
||||
a m t u n a t x o n g r t a c d
|
||||
r e m y l t b g i c e r i i
|
||||
s i l b n h t m u
|
||||
t n i l t a i a m
|
||||
a t n o r m l i
|
||||
m t b e n
|
||||
p t
|
||||
Database === === === === === === === === === === === === === === === ===
|
||||
mysql 38 5 5 69 2 3 16 2 4 1 2
|
||||
sakila 1 15 1 3 19 26 3 4 1 45 4 1 7 2
|
||||
|
||||
EOF
|
||||
format_overall_db_stats $samples/mysql-schema-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
Database Tables Views SPs Trigs Funcs FKs Partn
|
||||
{chosen} 1
|
||||
|
||||
Database InnoDB
|
||||
{chosen} 1
|
||||
|
||||
Database BTREE
|
||||
{chosen} 2
|
||||
|
||||
t v
|
||||
i a
|
||||
n r
|
||||
y c
|
||||
i h
|
||||
n a
|
||||
t r
|
||||
Database === ===
|
||||
{chosen} 1 1
|
||||
|
||||
EOF
|
||||
format_overall_db_stats $samples/mysql-schema-002.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ###########################################################################
|
||||
# format_innodb_status
|
||||
# ###########################################################################
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.001.txt"
|
||||
# ############################################################################
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Checkpoint Age | 619k
|
||||
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 3 Seconds
|
||||
History List Len | 255
|
||||
Read Views | 23
|
||||
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
|
||||
Pending I/O Reads | 14 buf pool reads, 6 normal AIO, 0 ibuf AIO, 23 preads
|
||||
Pending I/O Writes | 63 buf pool (63 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (1 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 1 log
|
||||
Transaction States | 1xACTIVE
|
||||
Semaphore Waits
|
||||
69 btr/btr0cur.c line 457
|
||||
47 btr/btr0cur.c line 523
|
||||
17 trx/trx0trx.c line 1621
|
||||
12 row/row0sel.c line 3549
|
||||
4 lock/lock0lock.c line 4944
|
||||
3 lock/lock0lock.c line 5316
|
||||
2 lock/lock0lock.c line 3224
|
||||
2 btr/btr0sea.c line 1032
|
||||
1 trx/trx0trx.c line 738
|
||||
1 row/row0sel.c line 4574
|
||||
1 lock/lock0lock.c line 5163
|
||||
1 lock/lock0lock.c line 3249
|
||||
1 ./include/btr0btr.ic line 53
|
||||
1 fsp/fsp0fsp.c line 3395
|
||||
1 btr/btr0cur.c line 672
|
||||
1 btr/btr0cur.c line 450
|
||||
Semaphore Holders
|
||||
66 thread id 139960165583184
|
||||
45 thread id 139960567171408
|
||||
4 thread id 139960404199760
|
||||
1 thread id 139961215367504
|
||||
1 thread id 139960969292112
|
||||
1 thread id 139960676096336
|
||||
Mutexes/Locks Waited For
|
||||
65 lock on RW-latch at 0x905d33d0 '&new_index->lock'
|
||||
45 lock on RW-latch at 0x7f4bedbf8810 '&block->lock'
|
||||
30 Mutex at 0xf89ab0 '&kernel_mutex'
|
||||
15 lock on RW-latch at 0x90075530 '&btr_search_latch'
|
||||
4 lock on RW-latch at 0x90a42ca0 '&new_index->lock'
|
||||
1 lock on RW-latch at 0x90fe1c80 '&new_index->lock'
|
||||
1 lock on RW-latch at 0x90078f10 '&space->latch'
|
||||
1 lock on RW-latch at 0x7f4c0d3abba8 '&block->lock'
|
||||
1 lock on RW-latch at 0x7f4bfc558040 '&block->lock'
|
||||
1 lock on RW-latch at 0x7f4bd0a8c8d0 '&block->lock'
|
||||
EOF
|
||||
|
||||
format_innodb_status $samples/innodb-status.001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.002.txt"
|
||||
# ############################################################################
|
||||
cat <<'EOF' > $TMPDIR/expected
|
||||
Checkpoint Age | 348M
|
||||
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 4 Seconds
|
||||
History List Len | 426
|
||||
Read Views | 583
|
||||
Undo Log Entries | 71 transactions, 247 total undo, 46 max undo
|
||||
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
|
||||
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 0 log
|
||||
Transaction States | 1xACTIVE, 70xACTIVE (PREPARED)
|
||||
Tables Locked
|
||||
62 `citydb`.`player_buildings`
|
||||
46 `citydb`.`players`
|
||||
22 `citydb`.`city_grid`
|
||||
17 `citydb`.`player_stats`
|
||||
6 `citydb`.`player_contracts`
|
||||
1 `citydb`.`player_achievements`
|
||||
Semaphore Waits
|
||||
23 trx/trx0undo.c line 1796
|
||||
10 trx/trx0trx.c line 1888
|
||||
8 trx/trx0trx.c line 1033
|
||||
7 trx/trx0trx.c line 738
|
||||
1 lock/lock0lock.c line 3770
|
||||
1 ./include/log0log.ic line 322
|
||||
Mutexes/Locks Waited For
|
||||
33 Mutex at 0x2abf68b76a18 '&rseg->mutex'
|
||||
16 Mutex at 0x48ace40 '&kernel_mutex'
|
||||
1 Mutex at 0x2abf68b6c0d0 '&log_sys->mutex'
|
||||
EOF
|
||||
|
||||
format_innodb_status $samples/innodb-status.002.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.003.txt"
|
||||
# ############################################################################
|
||||
cat <<'EOF' > $TMPDIR/expected
|
||||
Checkpoint Age | 0
|
||||
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 35 Seconds
|
||||
History List Len | 11
|
||||
Read Views | 1
|
||||
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
|
||||
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
|
||||
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 0 log
|
||||
Transaction States | 1xACTIVE, 1xnot started
|
||||
Tables Locked
|
||||
1 `test`.`t`
|
||||
EOF
|
||||
|
||||
format_innodb_status $samples/innodb-status.003.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.004.txt"
|
||||
# ############################################################################
|
||||
cat <<'EOF' > $TMPDIR/expected
|
||||
Checkpoint Age | 93M
|
||||
InnoDB Queue | 9 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 263 Seconds
|
||||
History List Len | 1282
|
||||
Read Views | 10
|
||||
Undo Log Entries | 3 transactions, 276797 total undo, 153341 max undo
|
||||
Pending I/O Reads | 50 buf pool reads, 48 normal AIO, 0 ibuf AIO, 2 preads
|
||||
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 0 log
|
||||
Transaction States | 9xACTIVE, 57xnot started
|
||||
Semaphore Waits
|
||||
3 row/row0sel.c line 3495
|
||||
2 btr/btr0sea.c line 1024
|
||||
1 btr/btr0sea.c line 1170
|
||||
1 btr/btr0cur.c line 443
|
||||
1 btr/btr0cur.c line 1501
|
||||
Semaphore Holders
|
||||
7 thread id 1220999488
|
||||
1 thread id 1229429056
|
||||
Mutexes/Locks Waited For
|
||||
7 lock on RW-latch at 0x2aaab42120b8 created in file btr/btr0sea.c line 139
|
||||
1 lock on RW-latch at 0x2ab2c679a550 created in file buf/buf0buf.c line 550
|
||||
EOF
|
||||
|
||||
format_innodb_status $samples/innodb-status.004.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
|
||||
# ###########################################################################
|
||||
# section_innodb
|
||||
# ###########################################################################
|
||||
|
||||
test_format_innodb () {
|
||||
local NAME_VAL_LEN=25
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Version | 1.0.17-13.2
|
||||
Buffer Pool Size | 128.0M
|
||||
Buffer Pool Fill | 1%
|
||||
Buffer Pool Dirty | 0%
|
||||
File Per Table | OFF
|
||||
Page Size | 16k
|
||||
Log File Size | 2 * 1.5G = 3.0G
|
||||
Log Buffer Size | 8M
|
||||
Flush Method | 0
|
||||
Flush Log At Commit | 1
|
||||
XA Support | ON
|
||||
Checksums | ON
|
||||
Doublewrite | ON
|
||||
R/W I/O Threads | 4 4
|
||||
I/O Capacity | 200
|
||||
Thread Concurrency | 0
|
||||
Concurrency Tickets | 500
|
||||
Commit Concurrency | 0
|
||||
Txn Isolation Level | REPEATABLE-READ
|
||||
Adaptive Flushing | OFF
|
||||
Adaptive Checkpoint | estimate
|
||||
EOF
|
||||
|
||||
section_innodb $samples/temp001/percona-toolkit-mysql-variables $samples/temp001/percona-toolkit-mysql-status > $TMPDIR/got
|
||||
no_diff $TMPDIR/expected $TMPDIR/got
|
||||
}
|
||||
|
||||
test_format_innodb
|
||||
|
||||
|
||||
# ###########################################################################
|
||||
# format_innodb_filters
|
||||
# ###########################################################################
|
||||
|
||||
format_innodb_filters_test () {
|
||||
local NAME_VAL_LEN=20
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
binlog_do_db | foo
|
||||
binlog_ignore_db | mysql,test
|
||||
EOF
|
||||
|
||||
format_binlog_filters $samples/mysql-show-master-status-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
}
|
||||
|
||||
format_innodb_filters_test
|
||||
|
||||
# ###########################################################################
|
||||
# report_mysql_summary
|
||||
# ###########################################################################
|
||||
|
||||
OPT_SLEEP=1
|
||||
OPT_DUMP_SCHEMAS="mysql"
|
||||
NAME_VAL_LEN=25
|
||||
_NO_FALSE_NEGATIVES=1
|
||||
report_mysql_summary "$samples/tempdir" "percona-toolkit" | tail -n+3 > $TMPDIR/got
|
||||
no_diff "$TMPDIR/got" "$samples/expected_result_report_summary.txt"
|
||||
|
||||
# ###########################################################################
|
||||
# Done
|
||||
# ###########################################################################
|
1
t/lib/bash/report_mysql_info.t
Symbolic link
1
t/lib/bash/report_mysql_info.t
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../util/test-bash-functions
|
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TESTS=4
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
TEST_NAME="ps-mysqld-001.txt"
|
||||
res=$(find_my_cnf_file samples/ps-mysqld-001.txt)
|
||||
is "$res" "/tmp/12345/my.sandbox.cnf"
|
||||
|
||||
TEST_NAME="ps-mysqld-001.txt with port"
|
||||
res=$(find_my_cnf_file samples/ps-mysqld-001.txt 12346)
|
||||
is "$res" "/tmp/12346/my.sandbox.cnf"
|
||||
|
||||
TEST_NAME="ps-mysqld-004.txt"
|
||||
res=$(find_my_cnf_file samples/ps-mysqld-004.txt)
|
||||
is "$res" "/var/lib/mysql/my.cnf"
|
||||
|
||||
TEST_NAME="ps-mysqld-004.txt with port"
|
||||
res=$(find_my_cnf_file samples/ps-mysqld-004.txt 12345)
|
||||
is "$res" "/var/lib/mysql/my.cnf"
|
@@ -1,14 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
NAME_VAL_LEN=20
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
binlog_do_db | foo
|
||||
binlog_ignore_db | mysql,test
|
||||
EOF
|
||||
|
||||
format_binlog_filters samples/mysql-show-master-status-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,36 +0,0 @@
|
||||
#/bin/bash
|
||||
|
||||
TESTS=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
test_format_innodb () {
|
||||
local NAME_VAL_LEN=25
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Version | 1.0.17-13.2
|
||||
Buffer Pool Size | 128.0M
|
||||
Buffer Pool Fill | 1%
|
||||
Buffer Pool Dirty | 0%
|
||||
File Per Table | OFF
|
||||
Page Size | 16k
|
||||
Log File Size | 2 * 1.5G = 3.1G
|
||||
Log Buffer Size | 8M
|
||||
Flush Method | 0
|
||||
Flush Log At Commit | 1
|
||||
XA Support | ON
|
||||
Checksums | ON
|
||||
Doublewrite | ON
|
||||
R/W I/O Threads | 4 4
|
||||
I/O Capacity | 200
|
||||
Thread Concurrency | 0
|
||||
Concurrency Tickets | 500
|
||||
Commit Concurrency | 0
|
||||
Txn Isolation Level | REPEATABLE-READ
|
||||
Adaptive Flushing | OFF
|
||||
Adaptive Checkpoint | estimate
|
||||
EOF
|
||||
|
||||
_innodb samples/temp001/percona-toolkit-mysql-variables samples/temp001/percona-toolkit-mysql-status > $TMPDIR/got
|
||||
no_diff $TMPDIR/expected $TMPDIR/got
|
||||
}
|
||||
|
||||
test_format_innodb
|
@@ -1,147 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TESTS=4
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.001.txt"
|
||||
# ############################################################################
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Checkpoint Age | 619k
|
||||
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 3 Seconds
|
||||
History List Len | 255
|
||||
Read Views | 23
|
||||
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
|
||||
Pending I/O Reads | 14 buf pool reads, 6 normal AIO, 0 ibuf AIO, 23 preads
|
||||
Pending I/O Writes | 63 buf pool (63 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (1 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 1 log
|
||||
Transaction States | 1xACTIVE
|
||||
Semaphore Waits
|
||||
69 btr/btr0cur.c line 457
|
||||
47 btr/btr0cur.c line 523
|
||||
17 trx/trx0trx.c line 1621
|
||||
12 row/row0sel.c line 3549
|
||||
4 lock/lock0lock.c line 4944
|
||||
3 lock/lock0lock.c line 5316
|
||||
2 lock/lock0lock.c line 3224
|
||||
2 btr/btr0sea.c line 1032
|
||||
1 trx/trx0trx.c line 738
|
||||
1 row/row0sel.c line 4574
|
||||
1 lock/lock0lock.c line 5163
|
||||
1 lock/lock0lock.c line 3249
|
||||
1 ./include/btr0btr.ic line 53
|
||||
1 fsp/fsp0fsp.c line 3395
|
||||
1 btr/btr0cur.c line 672
|
||||
1 btr/btr0cur.c line 450
|
||||
Semaphore Holders
|
||||
66 thread id 139960165583184
|
||||
45 thread id 139960567171408
|
||||
4 thread id 139960404199760
|
||||
1 thread id 139961215367504
|
||||
1 thread id 139960969292112
|
||||
1 thread id 139960676096336
|
||||
Mutexes/Locks Waited For
|
||||
65 lock on RW-latch at 0x905d33d0 '&new_index->lock'
|
||||
45 lock on RW-latch at 0x7f4bedbf8810 '&block->lock'
|
||||
30 Mutex at 0xf89ab0 '&kernel_mutex'
|
||||
15 lock on RW-latch at 0x90075530 '&btr_search_latch'
|
||||
4 lock on RW-latch at 0x90a42ca0 '&new_index->lock'
|
||||
1 lock on RW-latch at 0x90fe1c80 '&new_index->lock'
|
||||
1 lock on RW-latch at 0x90078f10 '&space->latch'
|
||||
1 lock on RW-latch at 0x7f4c0d3abba8 '&block->lock'
|
||||
1 lock on RW-latch at 0x7f4bfc558040 '&block->lock'
|
||||
1 lock on RW-latch at 0x7f4bd0a8c8d0 '&block->lock'
|
||||
EOF
|
||||
|
||||
format_innodb_status samples/innodb-status.001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.002.txt"
|
||||
# ############################################################################
|
||||
cat <<'EOF' > $TMPDIR/expected
|
||||
Checkpoint Age | 348M
|
||||
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 4 Seconds
|
||||
History List Len | 426
|
||||
Read Views | 583
|
||||
Undo Log Entries | 71 transactions, 247 total undo, 46 max undo
|
||||
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
|
||||
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 0 log
|
||||
Transaction States | 1xACTIVE, 70xACTIVE (PREPARED)
|
||||
Tables Locked
|
||||
62 `citydb`.`player_buildings`
|
||||
46 `citydb`.`players`
|
||||
22 `citydb`.`city_grid`
|
||||
17 `citydb`.`player_stats`
|
||||
6 `citydb`.`player_contracts`
|
||||
1 `citydb`.`player_achievements`
|
||||
Semaphore Waits
|
||||
23 trx/trx0undo.c line 1796
|
||||
10 trx/trx0trx.c line 1888
|
||||
8 trx/trx0trx.c line 1033
|
||||
7 trx/trx0trx.c line 738
|
||||
1 lock/lock0lock.c line 3770
|
||||
1 ./include/log0log.ic line 322
|
||||
Mutexes/Locks Waited For
|
||||
33 Mutex at 0x2abf68b76a18 '&rseg->mutex'
|
||||
16 Mutex at 0x48ace40 '&kernel_mutex'
|
||||
1 Mutex at 0x2abf68b6c0d0 '&log_sys->mutex'
|
||||
EOF
|
||||
|
||||
format_innodb_status samples/innodb-status.002.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.003.txt"
|
||||
# ############################################################################
|
||||
cat <<'EOF' > $TMPDIR/expected
|
||||
Checkpoint Age | 0k
|
||||
InnoDB Queue | 0 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 35 Seconds
|
||||
History List Len | 11
|
||||
Read Views | 1
|
||||
Undo Log Entries | 0 transactions, 0 total undo, 0 max undo
|
||||
Pending I/O Reads | 0 buf pool reads, 0 normal AIO, 0 ibuf AIO, 0 preads
|
||||
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 0 log
|
||||
Transaction States | 1xACTIVE, 1xnot started
|
||||
Tables Locked
|
||||
1 `test`.`t`
|
||||
EOF
|
||||
|
||||
format_innodb_status samples/innodb-status.003.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
# ############################################################################
|
||||
TEST_NAME="innodb-status.004.txt"
|
||||
# ############################################################################
|
||||
cat <<'EOF' > $TMPDIR/expected
|
||||
Checkpoint Age | 93M
|
||||
InnoDB Queue | 9 queries inside InnoDB, 0 queries in queue
|
||||
Oldest Transaction | 263 Seconds
|
||||
History List Len | 1282
|
||||
Read Views | 10
|
||||
Undo Log Entries | 3 transactions, 276797 total undo, 153341 max undo
|
||||
Pending I/O Reads | 50 buf pool reads, 48 normal AIO, 0 ibuf AIO, 2 preads
|
||||
Pending I/O Writes | 0 buf pool (0 LRU, 0 flush list, 0 page); 0 AIO, 0 sync, 0 log IO (0 log, 0 chkp); 0 pwrites
|
||||
Pending I/O Flushes | 0 buf pool, 0 log
|
||||
Transaction States | 9xACTIVE, 57xnot started
|
||||
Semaphore Waits
|
||||
3 row/row0sel.c line 3495
|
||||
2 btr/btr0sea.c line 1024
|
||||
1 btr/btr0sea.c line 1170
|
||||
1 btr/btr0cur.c line 443
|
||||
1 btr/btr0cur.c line 1501
|
||||
Semaphore Holders
|
||||
7 thread id 1220999488
|
||||
1 thread id 1229429056
|
||||
Mutexes/Locks Waited For
|
||||
7 lock on RW-latch at 0x2aaab42120b8 created in file btr/btr0sea.c line 139
|
||||
1 lock on RW-latch at 0x2ab2c679a550 created in file buf/buf0buf.c line 550
|
||||
EOF
|
||||
|
||||
format_innodb_status samples/innodb-status.004.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,61 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=2
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
Database Tables Views SPs Trigs Funcs FKs Partn
|
||||
mysql 17
|
||||
sakila 17 7 3 6 3 22 1
|
||||
|
||||
Database MyISAM InnoDB
|
||||
mysql 17
|
||||
sakila 2 15
|
||||
|
||||
Database BTREE FULLTEXT
|
||||
mysql 24
|
||||
sakila 63 1
|
||||
|
||||
c t s e t s i t b l b v d y d m
|
||||
h i e n i m n e l o i a a e e e
|
||||
a m t u n a t x o n g r t a c d
|
||||
r e m y l t b g i c e r i i
|
||||
s i l b n h t m u
|
||||
t n i l t a i a m
|
||||
a t n o r m l i
|
||||
m t b e n
|
||||
p t
|
||||
Database === === === === === === === === === === === === === === === ===
|
||||
mysql 38 5 5 69 2 3 16 2 4 1 2
|
||||
sakila 1 15 1 3 19 26 3 4 1 45 4 1 7 2
|
||||
|
||||
EOF
|
||||
format_overall_db_stats samples/mysql-schema-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
Database Tables Views SPs Trigs Funcs FKs Partn
|
||||
{chosen} 1
|
||||
|
||||
Database InnoDB
|
||||
{chosen} 1
|
||||
|
||||
Database BTREE
|
||||
{chosen} 2
|
||||
|
||||
t v
|
||||
i a
|
||||
n r
|
||||
y c
|
||||
i h
|
||||
n a
|
||||
t r
|
||||
Database === ===
|
||||
{chosen} 1 1
|
||||
|
||||
EOF
|
||||
format_overall_db_stats samples/mysql-schema-002.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,97 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Variable Per day Per second 5 secs
|
||||
Bytes_received 8000000 100
|
||||
Bytes_sent 35000000 400
|
||||
Com_admin_commands 20
|
||||
Com_change_db 1000
|
||||
Com_delete 8000
|
||||
Com_insert 8000
|
||||
Com_lock_tables 200
|
||||
Com_replace 1250
|
||||
Com_select 22500
|
||||
Com_set_option 22500
|
||||
Com_show_binlogs 10
|
||||
Com_show_create_db 400
|
||||
Com_show_create_table 7000
|
||||
Com_show_databases 125
|
||||
Com_show_fields 7000
|
||||
Com_show_innodb_status 300
|
||||
Com_show_open_tables 10
|
||||
Com_show_processlist 300
|
||||
Com_show_slave_status 300
|
||||
Com_show_status 350
|
||||
Com_show_storage_engines 10
|
||||
Com_show_tables 400
|
||||
Com_show_triggers 7000
|
||||
Com_show_variables 450
|
||||
Com_truncate 300
|
||||
Com_unlock_tables 250
|
||||
Com_update 900
|
||||
Connections 2500
|
||||
Created_tmp_disk_tables 15000
|
||||
Created_tmp_files 60
|
||||
Created_tmp_tables 22500
|
||||
Flush_commands 10
|
||||
Handler_delete 8000
|
||||
Handler_read_first 2250
|
||||
Handler_read_key 30000
|
||||
Handler_read_next 15000
|
||||
Handler_read_rnd 9000
|
||||
Handler_read_rnd_next 300000 3
|
||||
Handler_update 17500
|
||||
Handler_write 250000 2
|
||||
Innodb_buffer_pool_pages_data 225
|
||||
Innodb_buffer_pool_pages_free 5000
|
||||
Innodb_buffer_pool_pages_total 6000
|
||||
Innodb_buffer_pool_read_ahead_rnd 10
|
||||
Innodb_buffer_pool_read_requests 2250
|
||||
Innodb_buffer_pool_reads 150
|
||||
Innodb_data_fsyncs 35
|
||||
Innodb_data_read 30000000 350
|
||||
Innodb_data_reads 300
|
||||
Innodb_data_writes 35
|
||||
Innodb_data_written 17500
|
||||
Innodb_log_writes 10
|
||||
Innodb_os_log_fsyncs 35
|
||||
Innodb_os_log_written 6000
|
||||
Innodb_page_size 175000 2
|
||||
Innodb_pages_read 225
|
||||
Key_blocks_unused 150000 1
|
||||
Key_blocks_used 175
|
||||
Key_read_requests 100000 1
|
||||
Key_reads 600
|
||||
Key_write_requests 70000
|
||||
Key_writes 17500
|
||||
Max_used_connections 45
|
||||
Open_files 1500
|
||||
Open_tables 700
|
||||
Opened_tables 15000
|
||||
Qcache_free_blocks 80
|
||||
Qcache_free_memory 175000000 2250
|
||||
Qcache_hits 8000
|
||||
Qcache_inserts 20000
|
||||
Qcache_not_cached 10000
|
||||
Qcache_queries_in_cache 225
|
||||
Qcache_total_blocks 600
|
||||
Questions 100000 1
|
||||
Select_scan 25000
|
||||
Sort_rows 8000
|
||||
Sort_scan 300
|
||||
Table_locks_immediate 50000 17500
|
||||
Table_locks_waited 10 1
|
||||
Threads_cached 35
|
||||
Threads_connected 10
|
||||
Threads_created 45
|
||||
Threads_running 10
|
||||
Uptime 90000 1 1
|
||||
Uptime_since_flush_status 90000 1
|
||||
EOF
|
||||
|
||||
join samples/mysql-status-00{1,2}.txt > $TMPDIR/in
|
||||
format_status_variables $TMPDIR/in > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
TEST_NAME="fuzz 49"
|
||||
is $(fuzz 49) "50"
|
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=3
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
TEST_NAME="get_mysql_timezone"
|
||||
cp samples/mysql-variables-001.txt $TMPDIR/percona-toolkit-mysql-variables
|
||||
is $(get_mysql_timezone "$TMPDIR/percona-toolkit-mysql-variables") "EDT"
|
||||
|
||||
TEST_NAME="get_mysql_uptime"
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
2010-05-27 11:38 (up 0+02:08:52)
|
||||
EOF
|
||||
cp samples/mysql-status-001.txt $TMPDIR/percona-toolkit-mysql-status
|
||||
local uptime="$(get_var Uptime $TMPDIR/percona-toolkit-mysql-status)"
|
||||
local current_time="$(echo -e "2010-05-27 11:38\n")"
|
||||
get_mysql_uptime "${uptime}" "${current_time}" > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
TEST_NAME="get_mysql_version"
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Version | 5.0.51a-24+lenny2 (Debian)
|
||||
Built On | debian-linux-gnu i486
|
||||
EOF
|
||||
cp samples/mysql-variables-001.txt $TMPDIR/percona-toolkit-mysql-variables
|
||||
get_mysql_version $TMPDIR/percona-toolkit-mysql-variables > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=4
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
_NO_FALSE_NEGATIVES=1
|
||||
|
||||
TEST_NAME="ps-mysqld-001.txt"
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
3306 /var/lib/mysql ? ? /var/run/mysqld/mysqld.sock
|
||||
12345 /tmp/12345/data ? ? /tmp/12345/mysql_sandbox12345.sock
|
||||
12346 /tmp/12346/data ? ? /tmp/12346/mysql_sandbox12346.sock
|
||||
EOF
|
||||
parse_mysqld_instances samples/ps-mysqld-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
TEST_NAME="ps-mysqld-002.txt"
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
/var/lib/mysql ? ? /var/lib/mysql/mysql.sock
|
||||
EOF
|
||||
parse_mysqld_instances samples/ps-mysqld-002.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
TEST_NAME="ps-mysqld-003.txt"
|
||||
#parse_mysqld_instances
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
3306 /mnt/data-store/mysql/data ? ? /tmp/mysql.sock
|
||||
EOF
|
||||
parse_mysqld_instances samples/ps-mysqld-003.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Port Data Directory Nice OOM Value Socket
|
||||
===== ========================== ==== ========= ======
|
||||
/var/db/mysql ? ?
|
||||
EOF
|
||||
|
||||
cat <<EOF > $TMPDIR/in
|
||||
mysql 767 0.0 0.9 3492 1100 v0 I 3:01PM 0:00.07 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/db/mysql/freebsd.hsd1.va.comcast.net..pid
|
||||
mysql 818 0.0 17.4 45292 20584 v0 I 3:01PM 0:02.28 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --user=mysql --log-error=/var/db/mysql/freebsd.hsd1.va.comcast.net..err --pid-file=/var/db/mysql/freebsd.hsd1.va.comcast.net..pid
|
||||
EOF
|
||||
parse_mysqld_instances $TMPDIR/in > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=4
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/plugins
|
||||
binlog ACTIVE STORAGE ENGINE NULL GPL
|
||||
partition ACTIVE STORAGE ENGINE NULL GPL
|
||||
ARCHIVE ACTIVE STORAGE ENGINE NULL GPL
|
||||
BLACKHOLE ACTIVE STORAGE ENGINE NULL GPL
|
||||
CSV ACTIVE STORAGE ENGINE NULL GPL
|
||||
FEDERATED DISABLED STORAGE ENGINE NULL GPL
|
||||
MEMORY ACTIVE STORAGE ENGINE NULL GPL
|
||||
InnoDB ACTIVE STORAGE ENGINE NULL GPL
|
||||
MyISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
MRG_MYISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
EOF
|
||||
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins InnoDB )" \
|
||||
"ACTIVE" \
|
||||
"Sanity test, finds InnoDB as active"
|
||||
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins some_plugin_that_doesnt_exist )" \
|
||||
"Not found" \
|
||||
"Doesn't find a nonexistent plugin"
|
||||
|
||||
echo "INNODB_CMP ACTIVE" >> $TMPDIR/plugins
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins "INNODB_CMP" )" \
|
||||
"ACTIVE"
|
||||
|
||||
cat <<EOF > $TMPDIR/plugins
|
||||
binlog ACTIVE STORAGE ENGINE NULL GPL
|
||||
mysql_native_password ACTIVE AUTHENTICATION NULL GPL
|
||||
mysql_old_password ACTIVE AUTHENTICATION NULL GPL
|
||||
MRG_MYISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
MyISAM ACTIVE STORAGE ENGINE NULL GPL
|
||||
CSV ACTIVE STORAGE ENGINE NULL GPL
|
||||
MEMORY ACTIVE STORAGE ENGINE NULL GPL
|
||||
FEDERATED DISABLED STORAGE ENGINE NULL GPL
|
||||
ARCHIVE ACTIVE STORAGE ENGINE NULL GPL
|
||||
BLACKHOLE ACTIVE STORAGE ENGINE NULL GPL
|
||||
InnoDB ACTIVE STORAGE ENGINE NULL GPL
|
||||
INNODB_TRX ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_LOCKS ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_LOCK_WAITS ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMP ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMP_RESET ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMPMEM ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
INNODB_CMPMEM_RESET ACTIVE INFORMATION SCHEMA NULL GPL
|
||||
PERFORMANCE_SCHEMA ACTIVE STORAGE ENGINE NULL GPL
|
||||
partition ACTIVE STORAGE ENGINE NULL GPL
|
||||
EOF
|
||||
|
||||
is \
|
||||
"$(get_plugin_status $TMPDIR/plugins "INNODB_CMP" )" \
|
||||
"ACTIVE" \
|
||||
"Doesn't get confused by multiple plugins with the same prefix"
|
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=2
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
[mysqld]
|
||||
datadir = /mnt/data/mysql
|
||||
socket = /mnt/data/mysql/mysql.sock
|
||||
old_passwords = 1
|
||||
ssl-key = /opt/mysql.pdns/.cert/server-key.pem
|
||||
ssl-cert = /opt/mysql.pdns/.cert/server-cert.pem
|
||||
ssl-ca = /opt/mysql.pdns/.cert/ca-cert.pem
|
||||
innodb_buffer_pool_size = 16M
|
||||
innodb_flush_method = O_DIRECT
|
||||
innodb_log_file_size = 64M
|
||||
innodb_log_buffer_size = 1M
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_file_per_table = 1
|
||||
ssl = 1
|
||||
server-id = 1
|
||||
log-bin = sl1-bin
|
||||
|
||||
[mysql.server]
|
||||
user = mysql
|
||||
basedir = /mnt/data
|
||||
|
||||
[mysqld_safe]
|
||||
log-error = /var/log/mysqld.log
|
||||
pid-file = /var/run/mysqld/mysqld.pid
|
||||
|
||||
[mysql]
|
||||
|
||||
[xtrabackup]
|
||||
target-dir = /data/backup
|
||||
EOF
|
||||
|
||||
pretty_print_cnf_file samples/my.cnf-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
||||
|
||||
|
||||
# TODO BUG NUMBER#
|
||||
cp samples/my.cnf-001.txt $TMPDIR/test_pretty_print_cnf_file
|
||||
echo "some_var_yadda=0" >> $TMPDIR/test_pretty_print_cnf_file
|
||||
echo "some_var_yadda = 0" >> $TMPDIR/expected
|
||||
|
||||
pretty_print_cnf_file $TMPDIR/test_pretty_print_cnf_file > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -13,11 +13,8 @@ use English qw(-no_match_vars);
|
||||
use PerconaTest;
|
||||
|
||||
my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
|
||||
push @ARGV, "$trunk/t/$tool/*.sh" unless @ARGV;
|
||||
system("$trunk/util/test-bash-functions $trunk/bin/$tool @ARGV");
|
||||
|
||||
require Test::More;
|
||||
Test::More->import( tests => 3 );
|
||||
use Test::More tests => 3;
|
||||
use File::Temp qw( tempdir );
|
||||
|
||||
local $ENV{PTDEBUG} = "";
|
||||
@@ -38,7 +35,7 @@ my @files = glob("$dir/*");
|
||||
|
||||
is(
|
||||
scalar @files,
|
||||
13,
|
||||
12,
|
||||
"And leaves all files in there"
|
||||
);
|
||||
|
||||
|
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
TEST_NAME="report_summary"
|
||||
OPT_SLEEP=1
|
||||
OPT_DUMP_SCHEMAS="mysql"
|
||||
NAME_VAL_LEN=25
|
||||
_NO_FALSE_NEGATIVES=1
|
||||
report_summary "samples/tempdir" "percona-toolkit" | tail -n+3 > $TMPDIR/got
|
||||
no_diff "$TMPDIR/got" "samples/expected_result_report_summary.txt"
|
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST=3
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
master semisync status | 0
|
||||
master trace level | 32, net wait (more information about network waits)
|
||||
master timeout in milliseconds | 10000
|
||||
master waits for slaves | ON
|
||||
master clients | 0
|
||||
master net_avg_wait_time | 0
|
||||
master net_wait_time | 0
|
||||
master net_waits | 0
|
||||
master no_times | 0
|
||||
master no_tx | 0
|
||||
master timefunc_failures | 0
|
||||
master tx_avg_wait_time | 0
|
||||
master tx_wait_time | 0
|
||||
master tx_waits | 0
|
||||
master wait_pos_backtraverse | 0
|
||||
master wait_sessions | 0
|
||||
master yes_tx | 0
|
||||
EOF
|
||||
|
||||
_semi_sync_stats_for "master" samples/mysql-variables-with-semisync.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/expected $TMPDIR/got
|
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
Binlogs | 20
|
||||
Zero-Sized | 3
|
||||
Total Size | 6.5G
|
||||
EOF
|
||||
|
||||
summarize_binlogs samples/mysql-master-logs-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/expected $TMPDIR/got
|
@@ -1,64 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTS=1
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
cat <<EOF > $TMPDIR/expected
|
||||
|
||||
Command COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
Binlog Dump 1 1 9000000 9000000
|
||||
Connect 2 2 6000000 5000000
|
||||
Query 2 2 0 0
|
||||
Sleep 150 0 150000 20000
|
||||
|
||||
User COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
acjcxx 4 0 0 0
|
||||
aecac 1 0 0 0
|
||||
babeecc 20 0 0 0
|
||||
centous 2 0 0 0
|
||||
crcpcpc 2 0 0 0
|
||||
crgcp4c 3 0 0 0
|
||||
eanecj 30 1 0 0
|
||||
ebace 10 0 0 0
|
||||
etace 80 0 0 0
|
||||
goate 8 0 0 0
|
||||
qjveec 1 0 0 0
|
||||
repl 1 1 9000000 9000000
|
||||
root 1 1 0 0
|
||||
system user 2 2 6000000 5000000
|
||||
|
||||
Host COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
10.14.82.196 6 0 0 0
|
||||
10.14.82.202 20 0 0 0
|
||||
10.17.85.100 9 0 0 0
|
||||
10.17.85.74 1 1 9000000 9000000
|
||||
10.17.85.86 35 0 0 0
|
||||
10.17.85.88 5 0 0 0
|
||||
10.17.85.90 10 0 0 0
|
||||
10.36.34.66 35 1 0 0
|
||||
2 2 6000000 5000000
|
||||
localhost 1 1 0 0
|
||||
someserver.woozle.com11 1 0 0 0
|
||||
someserver.woozle.com14 1 0 0 0
|
||||
someserver.woozle.com 40 0 0 0
|
||||
|
||||
db COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
aetecjc 175 1 0 0
|
||||
NULL 4 4 15000000 9000000
|
||||
|
||||
State COUNT(*) Working SUM(Time) MAX(Time)
|
||||
------------------------------ -------- ------- --------- ---------
|
||||
150 0 0 0
|
||||
Has read all relay log; waitin 1 1 300000 300000
|
||||
Has sent all binlog to slave; 1 1 9000000 9000000
|
||||
NULL 2 2 0 0
|
||||
Waiting for master to send eve 1 1 5000000 5000000
|
||||
|
||||
EOF
|
||||
|
||||
summarize_processlist samples/processlist-001.txt > $TMPDIR/got
|
||||
no_diff $TMPDIR/got $TMPDIR/expected
|
@@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEST=3
|
||||
TMPDIR=$TEST_TMPDIR
|
||||
|
||||
touch $TMPDIR/table_cache_tests
|
||||
|
||||
is \
|
||||
$(get_table_cache "$TMPDIR/table_cache_tests") \
|
||||
0 \
|
||||
"0 if neither table_cache nor table_open_cache are present"
|
||||
|
||||
cat <<EOF > $TMPDIR/table_cache_tests
|
||||
table_cache 5
|
||||
table_open_cache 4
|
||||
EOF
|
||||
|
||||
is \
|
||||
$(get_table_cache "$TMPDIR/table_cache_tests") \
|
||||
4 \
|
||||
"If there's a table_open_cache present, uses that"
|
||||
|
||||
cat <<EOF > $TMPDIR/table_cache_tests
|
||||
table_cache 5
|
||||
EOF
|
||||
|
||||
is \
|
||||
$(get_table_cache "$TMPDIR/table_cache_tests") \
|
||||
5 \
|
||||
"Otherwise, defaults to table_cache"
|
Reference in New Issue
Block a user