diff --git a/bin/pt-align b/bin/pt-align
index 3d42a4db..03038735 100755
--- a/bin/pt-align
+++ b/bin/pt-align
@@ -6,7 +6,6 @@
use strict;
use warnings FATAL => 'all';
-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
# Finds the max element in the list
sub max {
@@ -49,6 +48,8 @@ foreach my $l ( @lines ) {
printf $fmt, @$l;
}
+exit 0;
+
# ############################################################################
# Documentation
# ############################################################################
@@ -60,53 +61,38 @@ pt-align - Read lines and split them into words.
=head1 SYNOPSIS
-Usage: pt-align [OPTION...]
+Usage: pt-align [FILES]
+
+pt-align reads lines in files and splits them into words. This is useful for
+things like aligning the output of vmstat or iostat so it is easier to read.
=head1 DESCRIPTION
-This program reads in lines and splits them into words. It counts how many
-words each line has, and if there is one number that predominates, it assumes
-this is the number of words in each line. Then it discards all lines that
-don't have that many words, and looks at the 2nd line that DOES. It assumes
-this is the first non-header line. Based on whether each word looks numeric
-or not, it decides on column alignment. Finally, it goes through and decides
-how wide each column should be, and then prints them out.
+pt-align counts how many words each line has, and if there is one number that
+predominates, it assumes this is the number of words in each line. Then it
+discards all lines that don't have that many words, and looks at the 2nd line
+that does. It assumes this is the first non-header line. Based on whether
+each word looks numeric or not, it decides on column alignment. Finally, it
+goes through and decides how wide each column should be, and then prints them
+out.
-This is useful for things like aligning the output of vmstat or iostat so it
-is easier to read.
+The tool's behavior has some important consequences. Reading the entire input
+before formatting means that you can't use it for aligning data as it is
+generated incrementally, and you probably don't want to use this tool on very
+large files. Discarding lines with the wrong number of words means that some
+lines won't be printed.
-=head1 DOWNLOADING
+=head1 OPTIONS
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
-
- wget percona.com/get/percona-toolkit.tar.gz
-
- wget percona.com/get/percona-toolkit.rpm
-
- wget percona.com/get/percona-toolkit.deb
-
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
+This tool does not have any command-line options.
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-align ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Perl, DBI, DBD::mysql, and some core packages that ought to be
-installed in any reasonably new version of Perl.
+This tool requires Perl v5.8 or newer built with core modules.
=head1 BUGS
@@ -132,6 +118,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-collect b/bin/pt-collect
index bd18613f..b6355e40 100755
--- a/bin/pt-collect
+++ b/bin/pt-collect
@@ -4,28 +4,12 @@
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
-# Print a usage message and exit.
usage() {
if [ "${OPT_ERR}" ]; then
- echo "${OPT_ERR}"
+ echo "${OPT_ERR}" >&2
fi
- cat <<-USAGE
-Usage: $0 OPTIONS [MYSQL-OPTIONS]
- Collects diagnostic data on a MySQL server and stores it into files.
- The MYSQL-OPTIONS are standard options to connect to MySQL: -uhPpS. Any
- options or arguments that follow this tool's -digos options will be treated
- as options to pass directly to mysql and mysqladmin.
-Options: (required: -dfigmos)
- -d DESTINATION Where to store the resulting data; must already exist.
- -f PERCENT Exit if the disk is more than this percent full.
- -i INTERVAL How many seconds to collect data.
- -g Collect GDB stack traces.
- -m MEGABYTES Exit unless there are this many megabytes free disk space.
- -o Collect oprofile data; disables -s.
- -p PREFIX Store the data into files with this prefix (optional).
- -s Collect strace data.
- -t Collect tcpdump data.
- USAGE
+ echo "Usage: pt-collect -d -g -i -o -s [OPTIONS] [-- MYSQL-OPTIONS]" >&2
+ echo "For more information, 'man pt-collect' or 'perldoc $0'." >&2
exit 1
}
@@ -83,8 +67,9 @@ for o; do
esac
done
+
if [ -z "${OPT_d}" -o -z "${OPT_i}" -o -z "${OPT_o}" -o -z "${OPT_g}" -o -z "${OPT_s}" ]; then
- OPT_ERR="Missing command-line option."
+ OPT_ERR="Missing command-line argument."
usage
fi
@@ -241,17 +226,17 @@ echo "Gathering info for $d"
opcontrol --stop
opcontrol --dump
kill $(pidof oprofiled);
- opcontrol --save=aspersa_collect_$d
+ opcontrol --save=percona_toolkit_collect_$d
# Attempt to generate a report; if this fails, then just tell the user how
# to generate the report.
path_to_binary=$(which mysqld);
if [ "${path_to_binary}" -a -f "${path_to_binary}" ]; then
- opreport --demangle=smart --symbols --merge tgid session:aspersa_collect_$d "${path_to_binary}" > "$OPT_d/$d-opreport"
+ opreport --demangle=smart --symbols --merge tgid session:percona_toolkit_collect_$d "${path_to_binary}" > "$OPT_d/$d-opreport"
else
- echo "oprofile data saved to aspersa_collect_$d; you should now be able to get a report" > "$OPT_d/$d-opreport"
+ echo "oprofile data saved to percona_toolkit_collect_$d; you should now be able to get a report" > "$OPT_d/$d-opreport"
echo "by running something like" >> "$OPT_d/$d-opreport"
- echo "opreport --demangle=smart --symbols --merge tgid session:aspersa_collect_$d /path/to/mysqld" >> "$OPT_d/$d-opreport"
+ echo "opreport --demangle=smart --symbols --merge tgid session:percona_toolkit_collect_$d /path/to/mysqld" >> "$OPT_d/$d-opreport"
fi
elif [ "${OPT_s}" = "yes" ]; then
kill -s 2 ${strace_pid}
@@ -277,7 +262,7 @@ echo "Gathering info for $d"
# Finally, record what system we collected this data from.
hostname > "$OPT_d/$d-hostname"
-)200>/tmp/aspersa-collect-lockfile >> "$OPT_d/$d-output" 2>&1
+)200>/tmp/percona-toolkit-collect-lockfile >> "$OPT_d/$d-output" 2>&1
# ############################################################################
# Documentation
@@ -291,44 +276,77 @@ pt-collect - Collect information from a server for some period of time.
=head1 SYNOPSIS
-Usage: pt-collect [OPTION...]
+Usage: pt-collect -d -g -i -o -s [OPTIONS] [-- MYSQL-OPTIONS]
+
+pt-collect tool gathers a variety of information about a system for a period
+of time. It is typically executed when the stalk tool detects a condition
+and wants to collect information to assist in diagnosis. Four options
+must be specified on the command line: -dgios.
=head1 DESCRIPTION
-pt-collect focuses on gathering diagnostic data during a MySQL performance
-problem. It is typically executed by C.
+pt-collect creates a lock to ensure that only one instance runs at a time,
+and then saves a variety of performance and status data into files in the
+configured directory. Files are named with a timestamp so they can be
+grouped together. The tool is MySQL-centric by default, and gathers quite
+a bit of diagnostic data that's useful for understanding the behavior of
+a MySQL database server.
-=head1 DOWNLOADING
+Options after C<--> are passed to C and C.
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=head1 OPTIONS
- wget percona.com/get/percona-toolkit.tar.gz
+=over
- wget percona.com/get/percona-toolkit.rpm
+=item -d (required)
- wget percona.com/get/percona-toolkit.deb
+DESTINATION Where to store the resulting data; must already exist.
-You can also get individual tools from the latest release:
+=item -g (required)
- wget percona.com/get/TOOL
+Collect GDB stack traces.
-Replace C with the name of any tool.
+=item -i INTERVAL (required)
+
+How many seconds to collect data.
+
+=item -o (required)
+
+Collect oprofile data; disables -s.
+
+=item -s (required)
+
+Collect strace data.
+
+=item -f PERCENT
+
+Exit if the disk is more than this percent full.
+
+=item -m MEGABYTES
+
+Exit unless there are this many megabytes free disk space.
+
+=item -p PREFIX
+
+Store the data into files with this prefix (optional).
+
+=item -t
+
+Collect tcpdump data.
+
+=back
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-collect ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires Bash v3 or newer and assumes that these programs
+are installed, in the PATH, and executable: sysctl, top, vmstat, iostat,
+mpstat, lsof, mysql, mysqladmin, df, netstat, pidof, flock, and others
+depending on what command-line options are specified. If some of those
+programs are not available, the tool will still run but may print warnings.
=head1 BUGS
@@ -354,6 +372,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-diskstats b/bin/pt-diskstats
index c7346b4a..a80cd73b 100755
--- a/bin/pt-diskstats
+++ b/bin/pt-diskstats
@@ -4,6 +4,31 @@
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
+usage() {
+ if [ "${OPT_ERR}" ]; then
+ echo "${OPT_ERR}" >&2
+ fi
+ echo "Usage: pt-diskstats [OPTIONS] [FILES]" >&2
+ echo "For more information, 'man pt-diskstats' or 'perldoc $0'" >&2
+ exit 1
+}
+
+# Show current help and settings
+print_help() {
+ cat <<-HELP
+ You can control this program by key presses:
+ ------------------- Key ------------------- ---- Current Setting ----
+ A, D, S) Set the group-by mode ${OPT_g:-(none)}
+ c) Enter an awk regex to match column names ${OPT_c:-(none)}
+ d) Enter an awk regex to match disk names ${OPT_d:-(none)}
+ i) Set the sample size in seconds ${OPT_i:-(none)}
+ s) Set the redisplay interval in seconds ${OPT_s:-(none)}
+ p) Pause the program
+ q) Quit the program
+ ------------------- Press any key to continue -----------------------
+ HELP
+}
+
# ########################################################################
# A bunch of snippets of awk code, to be reused in the functions below.
# ########################################################################
@@ -259,7 +284,7 @@ design_print_formats() {
# last sample.
group_by_disk () {
[ -z "${awk_print_line}" ] && design_print_formats
- cat > /tmp/aspersa.awk < /tmp/percona-toolkit.awk < /tmp/aspersa.awk < /tmp/percona-toolkit.awk < /tmp/aspersa.awk < /tmp/percona-toolkit.awk <.
=head1 SYNOPSIS
-Usage: pt-diskstats [OPTION...]
+Usage: pt-diskstats [OPTIONS] [FILES]
+
+pt-diskstats reads F periodically, or files with the
+contents of F, aggregates the data, and prints it nicely.
=head1 DESCRIPTION
-The file read should look like this:
+pt-diskstats tool is similar to iostat, but has some advantages. It separates
+reads and writes, for example, and computes some things that iostat does in
+either incorrect or confusing ways. It is also menu-driven and interactive
+with several different ways to aggregate the data, and integrates well with
+the L tool. These properties make it very convenient for quickly
+drilling down into I/O performance at the desired level of granularity.
+
+This program works in two main modes. One way is to process a file with saved
+disk statistics, which you specify on the command line. The other way is to
+start a background process gathering samples at intervals and saving them into
+a file, and process this file in the foreground. In both cases, the tool is
+interactively controlled by keystrokes, so you can redisplay and slice the
+data flexibly and easily. If the tool is not attached to a terminal, it
+doesn't run interactively; it just processes and prints its output, then exits.
+Otherwise it loops until you exit with the 'q' key.
+
+If you press the '?' key, you will bring up the interactive help menu that
+shows which keys control the program.
+
+Files should have this format:
TS
@@ -656,38 +663,139 @@ The file read should look like this:
... et cetera
TS <-- must end with a TS line.
-=head1 DOWNLOADING
+See L for a detailed
+example of using the tool.
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=head1 OUTPUT
- wget percona.com/get/percona-toolkit.tar.gz
+The columns are as follows:
- wget percona.com/get/percona-toolkit.rpm
+=over
- wget percona.com/get/percona-toolkit.deb
+=item #ts
-You can also get individual tools from the latest release:
+The number of seconds of samples in the line. If there is only one, then
+the timestamp itself is shown, without the {curly braces}.
- wget percona.com/get/TOOL
+=item device
-Replace C with the name of any tool.
+The device name. If there is more than one device, then instead the number
+of devices aggregated into the line is shown, in {curly braces}.
+
+=item rd_mb_s
+
+The number of megabytes read per second, average, during the sampled interval.
+
+=item rd_cnc
+
+The average concurrency of the read operations, as computed by Little's Law
+(a.k.a. queueing theory).
+
+=item rd_rt
+
+The average response time of the read operations, in milliseconds.
+
+=item wr_mb_s
+
+Megabytes written per second, average.
+
+=item wr_cnc
+
+Write concurrency, similar to read concurrency.
+
+=item wr_rt
+
+Write response time, similar to read response time.
+
+=item busy
+
+The fraction of time that the device had at least one request in progress;
+this is what iostat calls %util (which is a misleading name).
+
+=item in_prg
+
+The number of requests that were in progress. Unlike the read and write
+concurrencies, which are averages that are generated from reliable numbers,
+this number is an instantaneous sample, and you can see that it might
+represent a spike of requests, rather than the true long-term average.
+
+=back
+
+In addition to the above columns, there are a few columns that are hidden by
+default. If you press the 'c' key, and then press Enter, you will blank out
+the regular expression pattern that selects columns to display, and you will
+then see the extra columns:
+
+=over
+
+=item rd_s
+
+The number of reads per second.
+
+=item rd_avkb
+
+The average size of the reads, in kilobytes.
+
+=item rd_mrg
+
+The percentage of read requests that were merged together in the disk
+scheduler before reaching the device.
+
+=item wr_s, wr_avgkb, and wr_mrg
+
+These are analogous to their rd_* cousins.
+
+=back
+
+=head1 OPTIONS
+
+Options must precede files on the command line.
+
+=over
+
+=item -c COLS
+
+Awk regex of which columns to include (default cnc|rt|mb|busy|prg).
+
+=item -d DEVICES
+
+Awk regex of which devices to include.
+
+=item -g GROUPBY
+
+Group-by mode (default disk); specify one of the following:
+
+ disk - Each line of output shows one disk device.
+ sample - Each line of output shows one sample of statistics.
+ all - Each line of output shows one sample and one disk device.
+
+=item -i INTERVAL
+
+In -g sample mode, include INTERVAL seconds per sample.
+
+=item -k KEEPFILE
+
+File to save diskstats samples in (default /tmp/diskstats-samples).
+If a non-default filename is used, it will be saved for later analysis.
+
+=item -n SAMPLES
+
+When in interactive mode, stop after N samples.
+
+=item -s INTERVAL
+
+Sample /proc/diskstats every N seconds (default 1).
+
+=back
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-diskstats ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Perl, DBI, DBD::mysql, and some core packages that ought to be
-installed in any reasonably new version of Perl.
+This tool requires Bash v3 or newer and the F filesystem unless
+reading from files.
=head1 BUGS
@@ -713,6 +821,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-mext b/bin/pt-mext
index c0de7c64..66014a8a 100755
--- a/bin/pt-mext
+++ b/bin/pt-mext
@@ -1,18 +1,15 @@
-#!/usr/bin/env bash
+#!/bin/sh
# This program is part of Percona Toolkit: http://www.percona.com/software/
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
usage() {
- echo "Usage: $0 [-r] -- commandline"
- echo " -r Relative: subtract each column from the previous column."
- echo " -- Option separator; after this, all arguments are passed"
- echo " to the program whose output mext will columnize."
- echo "mext columnizes repeated output from a program like mysqladmin extended:"
- echo " mext -r -- mysqladmin ext -i10 -c3"
- echo "You can also work with data from a file:"
- echo " mext -r -- cat mysqladmin-output.txt"
+ if [ "${OPT_ERR}" ]; then
+ echo "${OPT_ERR}" >&2
+ fi
+ echo "Usage: pt-mext [OPTIONS] -- COMMAND" >&2
+ echo "For more information, 'man pt-mext' or 'perldoc $0'" >&2
exit 1
}
@@ -102,47 +99,49 @@ rm -f $FILE*;
=head1 NAME
-pt-mext - Aggregate and summarize mysqladmin extended output.
+pt-mext - Look at many samples of MySQL C side-by-side.
=head1 SYNOPSIS
-Usage: pt-mext [OPTION...]
+Usage: pt-mext [OPTIONS] -- COMMAND
+
+pt-mext columnizes repeated output from a program like mysqladmin extended.
+
+Get output from C:
+
+ mext -r -- mysqladmin ext -i10 -c3"
+
+Get output from a file:
+
+ mext -r -- cat mysqladmin-output.txt
=head1 DESCRIPTION
-pt-mext aggregates and summarizes mysqladmin extended output.
+pt-mext executes the C you specify, and reads through the result one
+line at a time. It places each line into a temporary file. When it finds a
+blank line, it assumes that a new sample of SHOW GLOBAL STATUS is starting,
+and it creates a new temporary file. At the end of this process, it has a
+number of temporary files. It joins the temporary files together side-by-side
+and prints the result. If the L<"-r"> option is given, it first subtracts
+each sample from the one after it before printing results.
-=head1 DOWNLOADING
+=head1 OPTIONS
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=over
- wget percona.com/get/percona-toolkit.tar.gz
+=item -r
- wget percona.com/get/percona-toolkit.rpm
+Relative: subtract each column from the previous column.
- wget percona.com/get/percona-toolkit.deb
-
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
+=back
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-mext ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires the Bourne shell (F).
=head1 BUGS
@@ -168,6 +167,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary
index 58098c8c..44abc002 100755
--- a/bin/pt-mysql-summary
+++ b/bin/pt-mysql-summary
@@ -4,6 +4,15 @@
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
+usage() {
+ if [ "${OPT_ERR}" ]; then
+ echo "${OPT_ERR}" >&2
+ fi
+ echo "Usage: pt-mysql-summary [MYSQL-OPTIONS]" >&2
+ echo "For more information, 'man pt-mysql-summary' or 'perldoc $0'" >&2
+ exit 1
+}
+
# ########################################################################
# Some global setup is necessary for cross-platform compatibility, even
# when sourcing this script for testing purposes.
@@ -53,9 +62,9 @@ fuzzy_formula='
# symlink them to /etc/passwd and then run this program as root. Call this
# function with "rm" or "touch" as an argument.
temp_files() {
- for file in /tmp/aspersa{,-mysql-variables,-mysql-status,-innodb-status} \
- /tmp/aspersa{2,-mysql-databases,-mysql-processlist,-noncounters} \
- /tmp/aspersa-mysql{dump,-slave};
+ for file in /tmp/percona-toolkit{,-mysql-variables,-mysql-status,-innodb-status} \
+ /tmp/percona-toolkit{2,-mysql-databases,-mysql-processlist,-noncounters} \
+ /tmp/percona-toolkit-mysql{dump,-slave};
do
case "$1" in
touch)
@@ -118,16 +127,16 @@ secs_to_time () {
}'
}
-# gets a value from /tmp/aspersa-mysql-variables. Returns zero if it doesn't
+# gets a value from /tmp/percona-toolkit-mysql-variables. Returns zero if it doesn't
# exist.
get_var () {
- v="$($AP_AWK "\$1 ~ /^$1$/ { print \$2 }" /tmp/aspersa-mysql-variables)"
+ v="$($AP_AWK "\$1 ~ /^$1$/ { print \$2 }" /tmp/percona-toolkit-mysql-variables)"
echo "${v:-0}"
}
# Returns true if a variable exists
var_exists () {
- $AP_GREP "$1" /tmp/aspersa-mysql-variables >/dev/null 2>&1;
+ $AP_GREP "$1" /tmp/percona-toolkit-mysql-variables >/dev/null 2>&1;
}
# Returns "Enabled", "Disabled", or "Not Supported" depending on whether the
@@ -136,7 +145,7 @@ var_exists () {
# (string equal) to some value.
feat_on() {
if var_exists $1 ; then
- var="$($AP_AWK "\$1 ~ /^$1$/ { print \$2 }" /tmp/aspersa-mysql-variables)"
+ var="$($AP_AWK "\$1 ~ /^$1$/ { print \$2 }" /tmp/percona-toolkit-mysql-variables)"
if [ "${var}" = "ON" ]; then
echo "Enabled"
elif [ "${var}" = "OFF" -o "${var}" = "0" -o -z "${var}" ]; then
@@ -163,10 +172,10 @@ feat_on() {
fi
}
-# gets a value from /tmp/aspersa-mysql-status. Returns zero if it doesn't
+# gets a value from /tmp/percona-toolkit-mysql-status. Returns zero if it doesn't
# exist.
get_stat () {
- v="$($AP_AWK "\$1 ~ /^$1$/ { print \$2 }" /tmp/aspersa-mysql-status)"
+ v="$($AP_AWK "\$1 ~ /^$1$/ { print \$2 }" /tmp/percona-toolkit-mysql-status)"
echo "${v:-0}"
}
@@ -186,16 +195,16 @@ fuzzy_pct () {
# 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. The calling convention is that the data they need to run is prepared
-# first by putting it into /tmp/aspersa. Then code that's testing just needs to
-# put sample data into /tmp/aspersa and call it.
+# first by putting it into /tmp/percona-toolkit. Then code that's testing just needs to
+# put sample data into /tmp/percona-toolkit and call it.
# ##############################################################################
# Parses the output of 'ps -e -o args | $AP_GREP mysqld' or 'ps auxww...'
-# which should be in /tmp/aspersa.
+# which should be in /tmp/percona-toolkit.
parse_mysqld_instances () {
echo " Port Data Directory Socket"
echo " ===== ========================== ======"
- $AP_GREP '/mysqld ' /tmp/aspersa | while read line; do
+ $AP_GREP '/mysqld ' /tmp/percona-toolkit | while read line; do
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
@@ -214,21 +223,21 @@ parse_mysqld_instances () {
}
# Tries to find the my.cnf file by examining 'ps' output, which should be in
-# /tmp/aspersa. You have to specify the port for the instance you are
+# /tmp/percona-toolkit. You have to specify the port for the instance you are
# interested in, in case there are multiple instances.
find_my_cnf_file() {
- if test -n "$1" && $AP_GREP -- "/mysqld.*--port=$1" /tmp/aspersa >/dev/null 2>&1 ; then
- $AP_GREP -- "/mysqld.*--port=$1" /tmp/aspersa \
+ if test -n "$1" && $AP_GREP -- "/mysqld.*--port=$1" /tmp/percona-toolkit >/dev/null 2>&1 ; then
+ $AP_GREP -- "/mysqld.*--port=$1" /tmp/percona-toolkit \
| $AP_AWK 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }' \
| head -n1
else
- $AP_GREP '/mysqld' /tmp/aspersa \
+ $AP_GREP '/mysqld' /tmp/percona-toolkit \
| $AP_AWK 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }' \
| head -n1
fi
}
-# Gets the MySQL system time. Uses input from /tmp/aspersa-mysql-variables.
+# Gets the MySQL system time. Uses input from /tmp/percona-toolkit-mysql-variables.
get_mysql_timezone () {
tz="$(get_var time_zone)"
if [ "${tz}" = "SYSTEM" ]; then
@@ -237,43 +246,43 @@ get_mysql_timezone () {
echo "${tz}"
}
-# Gets the MySQL system version. Uses input from /tmp/aspersa-mysql-variables.
+# Gets the MySQL system version. Uses input from /tmp/percona-toolkit-mysql-variables.
get_mysql_version () {
name_val Version "$(get_var version) $(get_var version_comment)"
name_val "Built On" "$(get_var version_compile_os) $(get_var version_compile_machine)"
}
# Gets the system start and uptime in human readable format. Last restart date
-# should be in /tmp/aspersa.
+# should be in /tmp/percona-toolkit.
get_mysql_uptime () {
- restart="$(cat /tmp/aspersa)"
+ restart="$(cat /tmp/percona-toolkit)"
uptime="$(get_stat Uptime)"
uptime="$(secs_to_time ${uptime})"
echo "${restart} (up ${uptime})"
}
-# Summarizes the output of SHOW MASTER LOGS, which is in /tmp/aspersa
+# Summarizes the output of SHOW MASTER LOGS, which is in /tmp/percona-toolkit
summarize_binlogs () {
- name_val "Binlogs" $(wc -l /tmp/aspersa)
- name_val "Zero-Sized" $($AP_GREP -c '\<0$' /tmp/aspersa)
- size=$($AP_AWK '{t += $2} END{printf "%0.f\n", t}' /tmp/aspersa)
+ name_val "Binlogs" $(wc -l /tmp/percona-toolkit)
+ name_val "Zero-Sized" $($AP_GREP -c '\<0$' /tmp/percona-toolkit)
+ size=$($AP_AWK '{t += $2} END{printf "%0.f\n", t}' /tmp/percona-toolkit)
name_val "Total Size" $(shorten ${size} 1)
}
# Print out binlog_do_db and binlog_ignore_db
format_binlog_filters () {
- name_val "binlog_do_db" $(cut -f3 /tmp/aspersa)
- name_val "binlog_ignore_db" $(cut -f4 /tmp/aspersa)
+ name_val "binlog_do_db" $(cut -f3 /tmp/percona-toolkit)
+ name_val "binlog_ignore_db" $(cut -f4 /tmp/percona-toolkit)
}
# Takes as input a file that has two samples of SHOW STATUS, columnized next to
-# each other. These should be in /tmp/aspersa. Outputs fuzzy-ed numbers:
+# each other. These should be in /tmp/percona-toolkit. 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 () {
# First, figure out the intervals.
- utime1=$($AP_AWK '/Uptime /{print $2}' /tmp/aspersa);
- utime2=$($AP_AWK '/Uptime /{print $3}' /tmp/aspersa);
+ utime1=$($AP_AWK '/Uptime /{print $2}' /tmp/percona-toolkit);
+ utime2=$($AP_AWK '/Uptime /{print $3}' /tmp/percona-toolkit);
${AP_AWK} "
BEGIN {
utime1 = ${utime1};
@@ -310,11 +319,11 @@ format_status_variables () {
printf(format, \$1, perday, persec, nowsec);
}
}
- }" /tmp/aspersa
+ }" /tmp/percona-toolkit
}
# Slices the processlist a bunch of different ways. Uses input from
-# /tmp/aspersa-mysql-processlist. The processlist should be created with the \G
+# /tmp/percona-toolkit-mysql-processlist. 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
@@ -329,7 +338,7 @@ summarize_processlist () {
"${param}" "COUNT(*)" Working "SUM(Time)" "MAX(Time)"
echo " ------------------------------" \
"-------- ------- --------- ---------"
- cut -c1-80 /tmp/aspersa-mysql-processlist \
+ cut -c1-80 /tmp/percona-toolkit-mysql-processlist \
| $AP_AWK "
\$1 == \"${param}:\" {
p = substr(\$0, index(\$0, \":\") + 2);
@@ -370,7 +379,7 @@ summarize_processlist () {
echo
}
-# Pretty-prints the my.cnf file, which should be in /tmp/aspersa. It's super
+# Pretty-prints the my.cnf file, which should be in /tmp/percona-toolkit. 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 [] and must remain that way.
@@ -394,7 +403,7 @@ pretty_print_cnf_file () {
else {
print $1;
}
- }' /tmp/aspersa
+ }' /tmp/percona-toolkit
}
find_checkpoint_age() {
@@ -526,8 +535,8 @@ format_innodb_status () {
name_val "Pending I/O Writes" "$(find_pending_io_writes "${1}")"
name_val "Pending I/O Flushes" "$(find_pending_io_flushes "${1}")"
$AP_AWK -F, '/^---TRANSACTION/{print $2}' "${1}" \
- | $AP_SED -e 's/ [0-9]* sec.*//' | sort | uniq -c > /tmp/aspersa2
- name_val "Transaction States" "$(group_concat /tmp/aspersa2)"
+ | $AP_SED -e 's/ [0-9]* sec.*//' | sort | uniq -c > /tmp/percona-toolkit2
+ name_val "Transaction States" "$(group_concat /tmp/percona-toolkit2)"
if $AP_GREP 'TABLE LOCK table' "${1}" >/dev/null ; then
echo "Tables Locked"
$AP_AWK '/^TABLE LOCK table/{print $4}' "${1}" \
@@ -613,9 +622,9 @@ format_overall_db_stats () {
printf fmt, db, counts[db ",tables"], counts[db ",views"], counts[db ",sps"], counts[db ",trg"], counts[db ",func"], counts[db ",fk"], counts[db ",partn"];
}
}
- ' /tmp/aspersa-mysqldump > /tmp/aspersa
- head -n2 /tmp/aspersa
- tail -n +3 /tmp/aspersa | sort
+ ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit
+ head -n2 /tmp/percona-toolkit
+ tail -n +3 /tmp/percona-toolkit | sort
echo
# Now do the summary of engines per DB
@@ -673,9 +682,9 @@ format_overall_db_stats () {
print "";
}
}
- ' /tmp/aspersa-mysqldump > /tmp/aspersa
- head -n1 /tmp/aspersa
- tail -n +2 /tmp/aspersa | sort
+ ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit
+ head -n1 /tmp/percona-toolkit
+ tail -n +2 /tmp/percona-toolkit | sort
echo
# Now do the summary of index types per DB. Careful -- index is a reserved
@@ -746,9 +755,9 @@ format_overall_db_stats () {
print "";
}
}
- ' /tmp/aspersa-mysqldump > /tmp/aspersa
- head -n1 /tmp/aspersa
- tail -n +2 /tmp/aspersa | sort
+ ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit
+ head -n1 /tmp/percona-toolkit
+ tail -n +2 /tmp/percona-toolkit | sort
echo
# Now do the summary of datatypes per DB
@@ -837,10 +846,10 @@ format_overall_db_stats () {
print "";
}
}
- ' /tmp/aspersa-mysqldump > /tmp/aspersa
- hdr=$($AP_GREP -n Database /tmp/aspersa | cut -d: -f1);
- head -n${hdr} /tmp/aspersa
- tail -n +$((${hdr} + 1)) /tmp/aspersa | sort
+ ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit
+ hdr=$($AP_GREP -n Database /tmp/percona-toolkit | cut -d: -f1);
+ head -n${hdr} /tmp/percona-toolkit
+ tail -n +$((${hdr} + 1)) /tmp/percona-toolkit | sort
echo
}
@@ -865,28 +874,28 @@ main() {
# ########################################################################
# Header for the whole thing, table of discovered instances
# ########################################################################
- section Aspersa_MySQL_Summary_Report
+ section Percona_Toolkit_MySQL_Summary_Report
name_val "System time" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)"
section Instances
- ps auxww 2>/dev/null | $AP_GREP mysqld > /tmp/aspersa
+ ps auxww 2>/dev/null | $AP_GREP mysqld > /tmp/percona-toolkit
parse_mysqld_instances
# ########################################################################
# Fetch some basic info so we can start
# ########################################################################
- mysql "$@" -ss -e 'SELECT CURRENT_USER()' > /tmp/aspersa
+ mysql "$@" -ss -e 'SELECT CURRENT_USER()' > /tmp/percona-toolkit
if [ "$?" != "0" ]; then
echo "Cannot connect to mysql, please specify command-line options."
temp_files "rm"
exit 1
fi
- user="$(cat /tmp/aspersa)";
- mysql -ss -e 'SHOW /*!40100 GLOBAL*/ VARIABLES' "$@" > /tmp/aspersa-mysql-variables
- mysql -ss -e 'SHOW /*!50000 GLOBAL*/ STATUS' "$@" > /tmp/aspersa-mysql-status
- mysql -ss -e 'SHOW DATABASES' "$@" > /tmp/aspersa-mysql-databases 2>/dev/null
- mysql -ssE -e 'SHOW SLAVE STATUS' "$@" > /tmp/aspersa-mysql-slave 2>/dev/null
- mysql -ssE -e 'SHOW /*!50000 ENGINE*/ INNODB STATUS' "$@" > /tmp/aspersa-innodb-status 2>/dev/null
- mysql -ssE -e 'SHOW FULL PROCESSLIST' "$@" > /tmp/aspersa-mysql-processlist 2>/dev/null
+ user="$(cat /tmp/percona-toolkit)";
+ mysql -ss -e 'SHOW /*!40100 GLOBAL*/ VARIABLES' "$@" > /tmp/percona-toolkit-mysql-variables
+ mysql -ss -e 'SHOW /*!50000 GLOBAL*/ STATUS' "$@" > /tmp/percona-toolkit-mysql-status
+ mysql -ss -e 'SHOW DATABASES' "$@" > /tmp/percona-toolkit-mysql-databases 2>/dev/null
+ mysql -ssE -e 'SHOW SLAVE STATUS' "$@" > /tmp/percona-toolkit-mysql-slave 2>/dev/null
+ mysql -ssE -e 'SHOW /*!50000 ENGINE*/ INNODB STATUS' "$@" > /tmp/percona-toolkit-innodb-status 2>/dev/null
+ mysql -ssE -e 'SHOW FULL PROCESSLIST' "$@" > /tmp/percona-toolkit-mysql-processlist 2>/dev/null
now="$(mysql -ss -e 'SELECT NOW()' "$@")"
port="$(get_var port)"
@@ -901,16 +910,16 @@ main() {
uptime="$(get_stat Uptime)"
mysql -ss -e "SELECT LEFT(NOW() - INTERVAL ${uptime} SECOND, 16)" "$@" \
- > /tmp/aspersa
+ > /tmp/percona-toolkit
name_val Started "$(get_mysql_uptime)"
- name_val Databases "$($AP_GREP -c . /tmp/aspersa-mysql-databases)"
+ name_val Databases "$($AP_GREP -c . /tmp/percona-toolkit-mysql-databases)"
name_val Datadir "$(get_var datadir)"
procs="$(get_stat Threads_connected)"
procr="$(get_stat Threads_running)"
name_val Processes "$(fuzz ${procs}) connected, $(fuzz ${procr}) running"
- if [ -s /tmp/aspersa-mysql-slave ]; then slave=""; else slave="not "; fi
- slavecount=$($AP_GREP -c 'Binlog Dump' /tmp/aspersa-mysql-processlist)
+ if [ -s /tmp/percona-toolkit-mysql-slave ]; then slave=""; else slave="not "; fi
+ slavecount=$($AP_GREP -c 'Binlog Dump' /tmp/percona-toolkit-mysql-processlist)
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
@@ -932,7 +941,7 @@ main() {
sleep 10
# TODO: gather this data in the same format as normal: stats, TS line
mysql -ss -e 'SHOW /*!50000 GLOBAL*/ STATUS' "$@" \
- | join /tmp/aspersa-mysql-status - > /tmp/aspersa
+ | join /tmp/percona-toolkit-mysql-status - > /tmp/percona-toolkit
# Make a file with a list of things we want to omit because they aren't
# counters, they are gauges (in RRDTool terminology). Gauges are shown
# elsewhere in the output.
@@ -956,9 +965,9 @@ main() {
Threads_cached Threads_connected Threads_running \
Uptime_since_flush_status;
do
- echo "${var}" >> /tmp/aspersa-noncounters
+ echo "${var}" >> /tmp/percona-toolkit-noncounters
done
- format_status_variables | $AP_GREP -v -f /tmp/aspersa-noncounters
+ format_status_variables | $AP_GREP -v -f /tmp/percona-toolkit-noncounters
# ########################################################################
# Table cache
@@ -1035,22 +1044,22 @@ main() {
trg_arg="${trg_arg} ${triggers}";
fi
# Find out which databases to dump
- num_dbs="$($AP_GREP -c . /tmp/aspersa-mysql-databases)"
+ num_dbs="$($AP_GREP -c . /tmp/percona-toolkit-mysql-databases)"
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. "
read dbtodump
mysqldump --no-data --skip-comments \
--skip-add-locks --skip-add-drop-table --compact \
--skip-lock-all-tables --skip-lock-tables --skip-set-charset \
- ${trg_arg} "$@" ${dbtodump:---all-databases} > /tmp/aspersa-mysqldump
+ ${trg_arg} "$@" ${dbtodump:---all-databases} > /tmp/percona-toolkit-mysqldump
# 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 $AP_GREP 'CREATE TABLE' /tmp/aspersa-mysqldump >/dev/null 2>&1; then
+ if $AP_GREP 'CREATE TABLE' /tmp/percona-toolkit-mysqldump >/dev/null 2>&1; then
format_overall_db_stats
else
echo "Skipping schema analysis due to apparent error in dump file"
- rm -f /tmp/aspersa-mysqldump
+ rm -f /tmp/percona-toolkit-mysqldump
fi
else
echo "Skipping schema analysis"
@@ -1060,23 +1069,23 @@ main() {
# Noteworthy Technologies
# ########################################################################
section Noteworthy_Technologies
- if [ -e /tmp/aspersa-mysqldump ]; then
- if $AP_GREP FULLTEXT /tmp/aspersa-mysqldump > /dev/null; then
+ if [ -e /tmp/percona-toolkit-mysqldump ]; then
+ if $AP_GREP FULLTEXT /tmp/percona-toolkit-mysqldump > /dev/null; then
name_val "Full Text Indexing" Yes
else
name_val "Full Text Indexing" No
fi
- if $AP_GREP 'GEOMETRY\|POINT\|LINESTRING\|POLYGON' /tmp/aspersa-mysqldump > /dev/null; then
+ if $AP_GREP 'GEOMETRY\|POINT\|LINESTRING\|POLYGON' /tmp/percona-toolkit-mysqldump > /dev/null; then
name_val "Geospatial Types" Yes
else
name_val "Geospatial Types" No
fi
- if $AP_GREP 'FOREIGN KEY' /tmp/aspersa-mysqldump > /dev/null; then
+ if $AP_GREP 'FOREIGN KEY' /tmp/percona-toolkit-mysqldump > /dev/null; then
name_val "Foreign Keys" Yes
else
name_val "Foreign Keys" No
fi
- if $AP_GREP 'PARTITION BY' /tmp/aspersa-mysqldump > /dev/null; then
+ if $AP_GREP 'PARTITION BY' /tmp/percona-toolkit-mysqldump > /dev/null; then
name_val "Partitioning" Yes
else
name_val "Partitioning" No
@@ -1156,8 +1165,8 @@ main() {
name_val "Adaptive Flushing" $(get_var innodb_adaptive_flushing)
name_val "Adaptive Checkpoint" $(get_var innodb_adaptive_checkpoint)
- if [ -s /tmp/aspersa-innodb-status ]; then
- format_innodb_status /tmp/aspersa-innodb-status
+ if [ -s /tmp/percona-toolkit-innodb-status ]; then
+ format_innodb_status /tmp/percona-toolkit-innodb-status
fi
fi
@@ -1192,14 +1201,14 @@ main() {
section Binary_Logging
binlog=$(get_var log_bin)
if [ "${binlog}" ]; then
- mysql -ss -e 'SHOW MASTER LOGS' "$@" > /tmp/aspersa 2>/dev/null
+ mysql -ss -e 'SHOW MASTER LOGS' "$@" > /tmp/percona-toolkit 2>/dev/null
summarize_binlogs
format="$(get_var binlog_format)"
name_val binlog_format "${format:-STATEMENT}"
name_val expire_logs_days $(get_var expire_logs_days)
name_val sync_binlog $(get_var sync_binlog)
name_val server_id $(get_var server_id)
- mysql -ss -e 'SHOW MASTER STATUS' "$@" > /tmp/aspersa 2>/dev/null
+ mysql -ss -e 'SHOW MASTER STATUS' "$@" > /tmp/percona-toolkit 2>/dev/null
format_binlog_filters
fi
@@ -1233,7 +1242,7 @@ main() {
# If there is a my.cnf in a standard location, see if we can pretty-print it.
# ########################################################################
section Configuration_File
- ps auxww 2>/dev/null | $AP_GREP mysqld > /tmp/aspersa
+ ps auxww 2>/dev/null | $AP_GREP mysqld > /tmp/percona-toolkit
cnf_file=$(find_my_cnf_file ${port});
if [ ! -e "${cnf_file}" ]; then
name_val "Config File" "Cannot autodetect, trying common locations"
@@ -1247,7 +1256,7 @@ main() {
fi
if [ -e "${cnf_file}" ]; then
name_val "Config File" "${cnf_file}"
- cat "${cnf_file}" > /tmp/aspersa
+ cat "${cnf_file}" > /tmp/percona-toolkit
pretty_print_cnf_file
else
name_val "Config File" "Cannot autodetect or find, giving up"
@@ -1275,52 +1284,57 @@ pt-mysql-summary - Summarize MySQL information in a nice way.
=head1 SYNOPSIS
-Usage: pt-mysql-summary [OPTION...]
+Usage: pt-mysql-summary [MYSQL-OPTIONS]
+
+pt-mysql-summary conveniently summarizes the status and configuration of a
+MySQL database server so that you can learn about it at a glance. It is not
+a tuning tool or diagnosis tool. It produces a report that is easy to diff
+and can be pasted into emails without losing the formatting. It should work
+well on any modern UNIX systems.
=head1 DESCRIPTION
-Goals: work well on all UNIXes; create a compact diff-able report that is
-easy to paste into a wiki or email, and easy to scan and compare too.
+pt-mysql-summary works by connecting to a MySQL database server and querying
+it for status and configuration information. It saves these bits of data
+into files in /tmp, and then formats them neatly with awk and other scripting
+languages.
To use, simply execute it. Optionally add the same command-line options
-you would use to connect to MySQL, such as "./mysql-summary --user=foo"
+you would use to connect to MySQL, like C.
-=head1 TODO
+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
+assumes that it will be able to find the my.cnf configuration file, for
+example. However, it should degrade gracefully if this is not the case.
+Note, however, that its output does not indicate which information comes from
+the MySQL database and which comes from the host operating system, so it is
+possible for confusing output to be generated if you run the tool on one
+server and direct it to connect to a MySQL database server running on another
+server.
- * Parse queries out of processlist and aggregate them.
+=head1 Fuzzy-Rounding
-=head1 DOWNLOADING
+Many of the outputs from this tool are deliberately rounded to show their
+magnitude but not the exact detail. This is called fuzzy-rounding. The idea
+is that it doesn't matter whether a server is running 918 queries per second
+or 921 queries per second; such a small variation is insignificant, and only
+makes the output hard to compare to other servers. Fuzzy-rounding rounds in
+larger increments as the input grows. It begins by rounding to the nearest 5,
+then the nearest 10, nearest 25, and then repeats by a factor of 10 larger
+(50, 100, 250), and so on, as the input grows.
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=head1 OPTIONS
- wget percona.com/get/percona-toolkit.tar.gz
-
- wget percona.com/get/percona-toolkit.rpm
-
- wget percona.com/get/percona-toolkit.deb
-
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
+This tool does not have any command-line options of its own. All options
+are passed to C.
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-mysql-summary ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Perl, DBI, DBD::mysql, and some core packages that ought to be
-installed in any reasonably new version of Perl.
+This tool requires Bash v3 or newer.
=head1 BUGS
@@ -1346,6 +1360,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-pmp b/bin/pt-pmp
index f107d488..394b0595 100755
--- a/bin/pt-pmp
+++ b/bin/pt-pmp
@@ -4,23 +4,12 @@
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
-# Print a usage message and exit.
usage() {
if [ "${OPT_ERR}" ]; then
- echo "${OPT_ERR}"
+ echo "${OPT_ERR}" >&2
fi
- cat <<-USAGE
-Usage: $0 [OPTIONS] [FILE]
- $0 does two things: 1) get a GDB backtrace 2) aggregate it.
- If you specify a FILE, then step 1) is not performed.
-Options:
- -b BINARY Which binary to trace (default mysqld)
- -i ITERATIONS How many traces to gather and aggregate (default 1)
- -k KEEPFILE Keep the raw traces in this file after aggregation
- -l NUMBER Aggregate only first NUMBER functions; 0=infinity (default 0)
- -p PID Process ID of the process to trace; overrides -b
- -s SLEEPTIME Number of seconds to sleep between iterations (default 0)
- USAGE
+ echo "Usage: pt-pmp [OPTIONS] [FILES]" >&2
+ echo "For more information, 'man pt-pmp' or 'perldoc $0'" >&2
exit 1
}
@@ -29,7 +18,7 @@ Options:
# to pass the maxlen argument into this function to make maxlen testable.
aggregate_stacktrace() {
maxlen="$1";
- cat > /tmp/aspersa.awk < /tmp/percona-toolkit.awk <> "${OPT_k:-/tmp/aspersa}"
- date +'TS %N.%s %F %T' >> "${OPT_k:-/tmp/aspersa}"
+ gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $OPT_p >> "${OPT_k:-/tmp/percona-toolkit}"
+ date +'TS %N.%s %F %T' >> "${OPT_k:-/tmp/percona-toolkit}"
sleep $OPT_s
done
fi
if [ $# -eq 0 ]; then
- aggregate_stacktrace "${OPT_l}" "${OPT_k:-/tmp/aspersa}"
- rm -f /tmp/aspersa
+ aggregate_stacktrace "${OPT_l}" "${OPT_k:-/tmp/percona-toolkit}"
+ rm -f /tmp/percona-toolkit
else
aggregate_stacktrace "${OPT_l}" "$@"
fi
@@ -199,44 +188,63 @@ pt-pmp - Aggregate GDB stack traces for a selected program.
=head1 SYNOPSIS
-Usage: pt-pmp [OPTION...]
+Usage: pt-pmp [OPTIONS] [FILES]
+
+pt-pmp is a poor man's profiler, inspired by L.
+It can create and summarize full stack traces of processes on Linux.
+Summaries of stack traces can be an invaluable tool for diagnosing what
+a process is waiting for.
=head1 DESCRIPTION
-pt-pmp aggregates stack traces.
+pt-pmp performs two tasks: it gets a stack trace, and it summarizes the stack
+trace. If a file is given on the command line, the tool skips the first step
+and just aggregates the file.
-=head1 DOWNLOADING
+To summarize the stack trace, the tool extracts the function name (symbol)
+from each level of the stack, and combines them with commas. It does this
+for each thread in the output. Afterwards, it sorts similar threads together
+and counts how many of each one there are, then sorts them most-frequent first.
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=head1 OPTIONS
- wget percona.com/get/percona-toolkit.tar.gz
+Options must precede files on the command line.
- wget percona.com/get/percona-toolkit.rpm
+=over
- wget percona.com/get/percona-toolkit.deb
+=item -b BINARY
-You can also get individual tools from the latest release:
+Which binary to trace (default mysqld)
- wget percona.com/get/TOOL
+=item -i ITERATIONS
-Replace C with the name of any tool.
+How many traces to gather and aggregate (default 1)
+
+=item -k KEEPFILE
+
+Keep the raw traces in this file after aggregation
+
+=item -l NUMBER
+
+Aggregate only first NUMBER functions; 0=infinity (default 0)
+
+=item -p PID
+
+Process ID of the process to trace; overrides -b
+
+=item -s SLEEPTIME
+
+Number of seconds to sleep between iterations (default 0)
+
+=back
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-pmp ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Perl, DBI, DBD::mysql, and some core packages that ought to be
-installed in any reasonably new version of Perl.
+This tool requires Bash v3 or newer.
=head1 BUGS
@@ -262,6 +270,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz, based on a script by Domas Mituzas (L)
diff --git a/bin/pt-rel b/bin/pt-rel
index 85dbd22f..bac1cc8c 100755
--- a/bin/pt-rel
+++ b/bin/pt-rel
@@ -53,7 +53,6 @@ while ( my $line = <$fh> ) {
}
}
-
close $fh or warn "Cannot close $file: $OS_ERROR";
exit;
@@ -61,14 +60,17 @@ exit;
=head1 NAME
-rel - Make each number in a line of text relative to the previous matching line.
+pt-rel - Relativize values to previous matching lines.
=head1 SYNOPSIS
-Given a file with some lines of text that follow a repeated pattern, including
-numbers,
+Usage: pt-rel [FILES]
- rel /path/to/file.txt
+pt-rel matches lines and subtracts the value of the previous line's values
+from the current line's values. The lines must be text with numeric values
+that repeat, varying only the values.
+
+=head1 DESCRIPTION
For example, if the text is this:
@@ -77,30 +79,20 @@ For example, if the text is this:
Mutex spin waits 0, rounds 99591465498, OS waits 437698122
RW-shared spins 834352175, OS waits 20259032; RW-excl spins 1769762980
-The output will be
+Then the output will be:
Mutex spin waits 0, rounds 99584819933, OS waits 437663963
RW-shared spins 834337527, OS waits 20258150; RW-excl spins 1769749834
Mutex spin waits 0, rounds 6645565, OS waits 34159
RW-shared spins 14648, OS waits 882; RW-excl spins 13146
-=head1 DOWNLOADING
+The first values (line 1) for "Mutex spin waits", "rounds", and "OS waits"
+were subtracted from the second values (line 3); the same happened for values
+from lines 2 and 4.
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=head1 OPTIONS
- wget percona.com/get/percona-toolkit.tar.gz
-
- wget percona.com/get/percona-toolkit.rpm
-
- wget percona.com/get/percona-toolkit.deb
-
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
+This tool does not have any command-line options.
=head1 ENVIRONMENT
@@ -114,7 +106,7 @@ of output.
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires Perl v5.8 or newer.
=head1 BUGS
@@ -140,6 +132,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-sift b/bin/pt-sift
index f940e57c..a7229874 100755
--- a/bin/pt-sift
+++ b/bin/pt-sift
@@ -4,6 +4,15 @@
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
+usage() {
+ if [ "${OPT_ERR}" ]; then
+ echo "${OPT_ERR}" >&2
+ fi
+ echo "Usage: pt-sift FILE|PREFIX|DIRECTORY" >&2
+ echo "For more information, 'man pt-sift' or 'perldoc $0'." >&2
+ exit 1
+}
+
# Show current help and settings
print_help() {
cat <<-HELP
@@ -23,19 +32,6 @@ print_help() {
HELP
}
-usage() {
- if [ "${OPT_ERR}" ]; then
- echo "${OPT_ERR}"
- fi
- cat <<-USAGE
-Usage: $0 [OPTIONS] [FILE|PREFIX|DIRECTORY]
- $0 helps you browse the files written by the collect tool.
- If you specify a FILE or PREFIX, it browses only files with that prefix. If you
- specify a DIRECTORY, then it browses all files within that directory.
- USAGE
- exit 1
-}
-
# The main code that runs by default. Arguments are the command-line options.
main() {
@@ -55,7 +51,7 @@ main() {
fi
# If the programs we need don't exist, try to get them.
- for prog in align diskstats pmp mext; do
+ for prog in pt-align pt-diskstats pt-pmp pt-mext; do
if which $prog >/dev/null 2>&1 ; then
eval "PR_$prog"="$(which $prog)"
elif [ -f $prog -a -x $prog ]; then
@@ -64,7 +60,7 @@ main() {
eval "PR_$prog"="${BASEDIR}/$prog"
else
echo "Fetching $prog"
- curl http://aspersa.googlecode.com/svn/trunk/$prog > "$prog" && chmod +x "$prog"
+ curl http://percona.com/get/$prog > "$prog" && chmod +x "$prog"
eval "PR_$prog"="./$prog"
fi
done
@@ -471,47 +467,86 @@ fi
=head1 NAME
-pt-sift - Browses the files created by the collect tool.
+pt-sift - Browses files created by pt-collect.
=head1 SYNOPSIS
-Usage: pt-sift [OPTION...]
+Usage: pt-sift FILE|PREFIX|DIRECTORY
+
+pt-sift browses the files created by L. If you specify a
+FILE or PREFIX, it browses only files with that prefix. If you specify a
+DIRECTORY, then it browses all files within that directory.
=head1 DESCRIPTION
-pt-sift browses the files created by the collect tool.
+pt-sift downloads other tools that it might need, such as L,
+and then makes a list of the unique timestamp prefixes of all the files in
+the directory, as written by the L tool. If the user specified
+a timestamp on the command line, then it begins with that sample of data;
+otherwise it begins by showing a list of the timestamps and prompting for
+a selection. Thereafter, it displays a summary of the selected sample, and
+the user can navigate and inspect with keystrokes. The keystroke commands
+you can use are as follows:
-=head1 DOWNLOADING
+=over
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+=item d
- wget percona.com/get/percona-toolkit.tar.gz
+Sets the action to start the L tool on the sample's disk
+performance statistics.
- wget percona.com/get/percona-toolkit.rpm
+=item i
- wget percona.com/get/percona-toolkit.deb
+Sets the action to view the first INNODB STATUS sample in less.
-You can also get individual tools from the latest release:
+=item m
- wget percona.com/get/TOOL
+Displays the first 4 samples of SHOW STATUS counters side by side with the
+L tool.
-Replace C with the name of any tool.
+=item n
+
+Summarizes the first sample of netstat data in two ways: by originating host,
+and by connection state.
+
+=item j
+
+Select the next timestamp as the active sample.
+
+=item k
+
+Select the previous timestamp as the active sample.
+
+=item q
+
+Quit the program.
+
+=item 1
+
+Sets the action for each sample to the default, which is to view a summary
+of the sample.
+
+=item 0
+
+Sets the action to just list the files in the sample.
+
+=item *
+
+Sets the action to view all of the samples's files in the less program.
+
+=back
+
+=head1 OPTIONS
+
+This tool does not have any command-line options.
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-sift ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires Bash v3 or newer.
=head1 BUGS
@@ -537,6 +572,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz
diff --git a/bin/pt-stalk b/bin/pt-stalk
index bb365ac5..6e19f4ec 100755
--- a/bin/pt-stalk
+++ b/bin/pt-stalk
@@ -51,7 +51,7 @@ MAYBE_EMPTY=${MAYBE_EMPTY:-no}
# This is the location of the 'collect' script.
if [ -z "${COLLECT}" ]; then
- COLLECT="${HOME}/bin/collect";
+ COLLECT="${HOME}/bin/pt-collect";
fi
# This is where to store the collected data.
@@ -167,52 +167,155 @@ done
=head1 NAME
-pt-stalk - Watch MySQL and run the 'collect' program when some condition becomes true.
+pt-stalk - Wait for a condition to occur then begin collecting data.
=head1 SYNOPSIS
-Usage: pt-stalk [OPTION...]
+Usage: pt-stalk
+
+pt-stalk watches for a condition to become true, and when it does, executes
+a script. By default it executes L, but that can be customized.
+This tool is useful for gathering diagnostic data when an infrequent event
+occurs, so an expert person can review the data later.
=head1 DESCRIPTION
-By default, it watches for a too-many-connections condition.
-This is a good script to run in a screen session. It's separate from the
-'collect' script because that lets you change 'collect' without stopping
-and restarting this one.
+Although pt-stalk comes pre-configured to do a specific thing, in general
+this tool is just a skeleton script for the following flow of actions:
+
+=over
+
+=item 1.
+
+Loop infinitely, sleeping between iterations.
+
+=item 2.
+
+In each iteration, run some command and get the output.
+
+=item 3.
+
+If the command fails or the output is larger than the threshold,
+execute the collection script; but do not execute if the destination disk
+is too full.
+
+=back
+
+By default, the tool is configured to execute mysqladmin extended-status and
+extract the value of the Threads_connected variable; if this is greater than
+100, it runs the collection script. This is really just placeholder code,
+and almost certainly needs to be customized!
+
+If the tool does execute the collection script, it will wait for a while
+before checking and executing again. This is to prevent a continuous
+condition from causing a huge number of executions to fire off.
The name 'stalk' is because 'watch' is already taken, and 'stalk' is fun.
-=head1 DOWNLOADING
+=head1 CONFIGURING
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
+If the file F exists in the current working directory, then
+L<"ENVIRONMENT"> variables are imported from it. For example, the config
+file has the format:
- wget percona.com/get/percona-toolkit.tar.gz
+ INTERVAL=10
+ GDB=yes
- wget percona.com/get/percona-toolkit.rpm
+See L<"ENVIRONMENT">.
- wget percona.com/get/percona-toolkit.deb
+=head1 OPTIONS
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
+This tool does not have any command-line options, but see
+L<"ENVIRONMENT"> and L<"CONFIGURING">.
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
+The following environment variables configure how, what, and when the tool
+runs. They are all optional and can be specified either on the command line
+or in the F config file (see L<"CONFIGURING">).
- PTDEBUG=1 pt-stalk ... > FILE 2>&1
+=over
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+=item THRESHOLD (default 100)
+
+This is the max number of we want to tolerate.
+
+=item VARIABLE (default Threads_connected}
+
+This is the thing to check for.
+
+=item CYCLES (default 1)
+
+How many times must the condition be met before the script will fire?
+
+=item GDB (default no)
+
+Collect GDB stacktraces?
+
+=item OPROFILE (default yes)
+
+Collect oprofile data?
+
+=item STRACE (default no)
+
+Collect strace data?
+
+=item TCPDUMP (default yes)
+
+Collect tcpdump data?
+
+=item EMAIL
+
+Send mail to this list of addresses when the script triggers.
+
+=item MYSQLOPTIONS
+
+Any options to pass to mysql/mysqladmin, such as -u, -p, etc
+
+=item INTERVAL (default 30)
+
+This is the interval between checks.
+
+=item MAYBE_EMPTY (default no)
+
+If the command you're running to detect the condition is allowed to return
+nothing (e.g. a grep line that might not even exist if there's no problem),
+then set this to "yes".
+
+=item COLLECT (default ${HOME}/bin/pt-collect)
+
+This is the location of the 'collect' script.
+
+=item DEST (default ${HOME}/collected/)
+
+This is where to store the collected data.
+
+=item DURATION (default 30)
+
+How long to collect statistics data for? Make sure that this isn't longer
+than SLEEP.
+
+=item SLEEP (default DURATION * 10)
+
+How long to sleep after collecting?
+
+=item PCT_THRESHOLD (default 95)
+
+Bail out if the disk is more than this %full.
+
+=item MB_THRESHOLD (default 100)
+
+Bail out if the disk has less than this many MB free.
+
+=item PURGE (default 30)
+
+Remove samples after this many days.
+
+=back
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires Bash v3 or newer.
=head1 BUGS
@@ -238,6 +341,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz, Justin Swanhart, and Fernando Ipar
diff --git a/bin/pt-summary b/bin/pt-summary
index 66eb5c4b..aa9d1799 100755
--- a/bin/pt-summary
+++ b/bin/pt-summary
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# This program is part of Percona Toolkit: http://www.percona.com/software/
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
@@ -1187,53 +1187,46 @@ pt-summary - Summarize system information in a nice way.
=head1 SYNOPSIS
-Usage: pt-collect [OPTION...]
+Usage: pt-summary
+
+pt-summary conveniently summarizes the status and configuration of a server.
+It is not a tuning tool or diagnosis tool. It produces a report that is easy
+to diff and can be pasted into emails without losing the formatting. This
+tool works well on Linux systems.
+
+Download and run:
+
+ wget http://aspersa.googlecode.com/svn/trunk/summary
+ bash ./summary
+
+Download and run in a single step:
+
+ wget -O- http://aspersa.googlecode.com/svn/trunk/summary | bash
=head1 DESCRIPTION
-Goals: work well on Linux; create a compact diff-able report that is
-easy to paste into a wiki or email, and easy to scan and compare too.
+pt-summary runs a large variety of commands to inspect system status and
+configuration, saves the output into files in /tmp, and then runs Unix
+commands on these results to format them nicely. It works best when
+executed as a privileged user, but will also work without privileges,
+although some output might not be possible to generate without root.
-Usage: $ wget -O- http://aspersa.googlecode.com/svn/trunk/summary |bash
-Options are set through the ASPERSA_SKIP environment variable. Set this
-variable to a comma-separated list of things you want to omit.
+=head1 OPTIONS
+
+This tool does not have any command-line options.
+
+=head1 ENVIRONMENT
+
+The ASPERSA_SKIP environment variable specifies a comma-separated list
+of things to skip:
-Options:
MOUNT: Don't print out mounted filesystems and disk fullness.
NETWORK: Don't print out information on network controllers & config.
PROCESS: Don't print out top processes and vmstat information.
-=head1 DOWNLOADING
-
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
-
- wget percona.com/get/percona-toolkit.tar.gz
-
- wget percona.com/get/percona-toolkit.rpm
-
- wget percona.com/get/percona-toolkit.deb
-
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
-
-=head1 ENVIRONMENT
-
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-summary ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
-
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires the Bourne shell (F).
=head1 BUGS
@@ -1259,6 +1252,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz and Kevin van Zonneveld (http://kevin.vanzonneveld.net)
diff --git a/bin/pt-usl b/bin/pt-usl
index 99f0186f..0e1ac549 100755
--- a/bin/pt-usl
+++ b/bin/pt-usl
@@ -4,43 +4,12 @@
# See "COPYRIGHT, LICENSE, AND WARRANTY" at the end of this file for legal
# notices and disclaimers.
-# Print a usage message and exit.
usage() {
if [ "${OPT_ERR}" ]; then
- echo "${OPT_ERR}"
+ echo "${OPT_ERR}" >&2
fi
- cat <<-EOF
-Usage: $0 [OPTIONS] FILE [FILE...]
- $0 performs Universal Scalability Law modelling.
- It expects as input a file with columns N (load; concurrency; independentvar)
- and C (throughput). The file may contain comment lines beginning with the #
- character. The tool outputs .png images with the deviation, efficiency,
- residuals, and model-vs-actual data. It also prints out information from the
- process of fitting the curve to the data, such as gnuplot's error estimates.
-Options:
- -a Set X-axis label to 'node count' (default is concurrency).
- -c CONVERSION Converts the input file into N-vs-C format as specified:
- globalstatus Convert from MySQL's SHOW GLOBAL STATUS
- tcpdump Convert from 'tcpdump -tttt -nnq' format
- -d Don't delete the gnuplot files used to generate the charts.
- -e Draw error lines on the final plot.
- -i INTERVAL When -c is given, group the input into -i second intervals.
- -k KEEPFILE Save the N-vs-C data in the specified file.
- -l LIMIT X-axis limit for the final plot.
- -L COLOR The color for plotting points (default lt rgb "#8B0000").
- -m THREADS When -c is given, max valid value of N, to filter outliers.
- -n ADJUSTMENT Adjust the N variable downwards to compensate for known
- errors such as error of observation.
- -o ONLY Only produce plots specified in this comma-separated list.
- -p PREFIX Prefix for the generated image file names.
- -P PORT TCP port for when -c tcpdump is used (default 3306).
- -r Render pdf and eps plots in color.
- -R Don't re-fit the data; use the results from quadratic fit.
- -t FILETYPE Type for the image files (png, pdf, eps).
- -T POINTTYPE Point-type and options for the plots (default 6).
- -x ADJUSTMENT Multiply the C(1) regression parameter by this factor.
- -X Include C(1) as a fit parameter for USL regression.
- EOF
+ echo "Usage: pt-usl [OPTIONS] [FILES]" >&2
+ echo "For more information, 'man pt-usl' or 'perldoc $0'." >&2
exit 1
}
@@ -777,12 +746,45 @@ pt-usl - Model Universal Scalability Law.
=head1 SYNOPSIS
-Usage: pt-usl [OPTION...]
+Usage: pt-usl [OPTIONS] [FILES]
=head1 DESCRIPTION
This tool is based on Neil Gunther's book Guerrilla Capacity Planning.
+It expects as input a file with columns N (load; concurrency; independentvar)
+and C (throughput). The file may contain comment lines beginning with the #
+character. The tool outputs .png images with the deviation, efficiency,
+residuals, and model-vs-actual data. It also prints out information from the
+process of fitting the curve to the data, such as gnuplot's error estimates.
+
+=head1 OPTIONS
+
+Options must precede files on the command line.
+
+ -a Set X-axis label to 'node count' (default is concurrency).
+ -c CONVERSION Converts the input file into N-vs-C format as specified:
+ globalstatus Convert from MySQL's SHOW GLOBAL STATUS
+ tcpdump Convert from 'tcpdump -tttt -nnq' format
+ -d Don't delete the gnuplot files used to generate the charts.
+ -e Draw error lines on the final plot.
+ -i INTERVAL When -c is given, group the input into -i second intervals.
+ -k KEEPFILE Save the N-vs-C data in the specified file.
+ -l LIMIT X-axis limit for the final plot.
+ -L COLOR The color for plotting points (default lt rgb "#8B0000").
+ -m THREADS When -c is given, max valid value of N, to filter outliers.
+ -n ADJUSTMENT Adjust the N variable downwards to compensate for known
+ errors such as error of observation.
+ -o ONLY Only produce plots specified in this comma-separated list.
+ -p PREFIX Prefix for the generated image file names.
+ -P PORT TCP port for when -c tcpdump is used (default 3306).
+ -r Render pdf and eps plots in color.
+ -R Don't re-fit the data; use the results from quadratic fit.
+ -t FILETYPE Type for the image files (png, pdf, eps).
+ -T POINTTYPE Point-type and options for the plots (default 6).
+ -x ADJUSTMENT Multiply the C(1) regression parameter by this factor.
+ -X Include C(1) as a fit parameter for USL regression.
+
=head1 TODO
* Need to make it optionally make logarithmic X axis graph. Also, apply
@@ -794,37 +796,13 @@ This tool is based on Neil Gunther's book Guerrilla Capacity Planning.
other samples; it will introduce skew into the throughput for that sample,
too.
-=head1 DOWNLOADING
-
-Visit L to download the
-latest release of Percona Toolkit. Or, get the latest release from the
-command line:
-
- wget percona.com/get/percona-toolkit.tar.gz
-
- wget percona.com/get/percona-toolkit.rpm
-
- wget percona.com/get/percona-toolkit.deb
-
-You can also get individual tools from the latest release:
-
- wget percona.com/get/TOOL
-
-Replace C with the name of any tool.
-
=head1 ENVIRONMENT
-The environment variable C enables verbose debugging output to STDERR.
-To enable debugging and capture all output to a file, run the tool like:
-
- PTDEBUG=1 pt-usl ... > FILE 2>&1
-
-Be careful: debugging output is voluminous and can generate several megabytes
-of output.
+This tool does not use any environment variables.
=head1 SYSTEM REQUIREMENTS
-You need Bash.
+This tool requires Bash v3 or newer and gnuplot.
=head1 BUGS
@@ -850,6 +828,24 @@ Include the following information in your bug report:
If possible, include debugging output by running the tool with C;
see L<"ENVIRONMENT">.
+=head1 DOWNLOADING
+
+Visit L to download the
+latest release of Percona Toolkit. Or, get the latest release from the
+command line:
+
+ wget percona.com/get/percona-toolkit.tar.gz
+
+ wget percona.com/get/percona-toolkit.rpm
+
+ wget percona.com/get/percona-toolkit.deb
+
+You can also get individual tools from the latest release:
+
+ wget percona.com/get/TOOL
+
+Replace C with the name of any tool.
+
=head1 AUTHORS
Baron Schwartz