diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index bce26fb7..a237d4e6 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -202,9 +202,10 @@ fuzzy_pct () { # Parses the output of 'ps -e -o args | $AP_GREP mysqld' or 'ps auxww...' # which should be in /tmp/percona-toolkit. parse_mysqld_instances () { + local file=$1 echo " Port Data Directory Socket" echo " ===== ========================== ======" - $AP_GREP '/mysqld ' /tmp/percona-toolkit | while read line; do + $AP_GREP '/mysqld ' $file | 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 @@ -257,7 +258,8 @@ get_mysql_version () { # Gets the system start and uptime in human readable format. Last restart date # should be in /tmp/percona-toolkit. get_mysql_uptime () { - restart="$(cat /tmp/percona-toolkit)" + local file=$1 + restart="$(cat $file)" uptime="$(get_stat Uptime)" uptime="$(secs_to_time ${uptime})" echo "${restart} (up ${uptime})" @@ -265,16 +267,18 @@ get_mysql_uptime () { # Summarizes the output of SHOW MASTER LOGS, which is in /tmp/percona-toolkit summarize_binlogs () { - 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) + local file=$1 + name_val "Binlogs" $(wc -l $file) + name_val "Zero-Sized" $($AP_GREP -c '\<0$' $file) + size=$($AP_AWK '{t += $2} END{printf "%0.f\n", t}' $file) 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/percona-toolkit) - name_val "binlog_ignore_db" $(cut -f4 /tmp/percona-toolkit) + 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 @@ -282,9 +286,10 @@ format_binlog_filters () { # 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=$($AP_AWK '/Uptime /{print $2}' /tmp/percona-toolkit); - utime2=$($AP_AWK '/Uptime /{print $3}' /tmp/percona-toolkit); + utime1=$($AP_AWK '/Uptime /{print $2}' $file); + utime2=$($AP_AWK '/Uptime /{print $3}' $file); ${AP_AWK} " BEGIN { utime1 = ${utime1}; @@ -321,12 +326,12 @@ format_status_variables () { printf(format, \$1, perday, persec, nowsec); } } - }" /tmp/percona-toolkit + }" $file } -# Slices the processlist a bunch of different ways. Uses input from -# /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 +# 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 @@ -334,13 +339,14 @@ format_status_variables () { # 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 echo printf ' %-30s %8s %7s %9s %9s\n' \ "${param}" "COUNT(*)" Working "SUM(Time)" "MAX(Time)" echo " ------------------------------" \ "-------- ------- --------- ---------" - cut -c1-80 /tmp/percona-toolkit-mysql-processlist \ + cut -c1-80 $file \ | $AP_AWK " \$1 == \"${param}:\" { p = substr(\$0, index(\$0, \":\") + 2); @@ -386,6 +392,7 @@ summarize_processlist () { # sets in regular expressions, like [[:space:]] (looking at you, Debian). So # the below patterns contain [] and must remain that way. pretty_print_cnf_file () { + local file=$1 $AP_AWK ' BEGIN { FS="=" @@ -405,7 +412,7 @@ pretty_print_cnf_file () { else { print $1; } - }' /tmp/percona-toolkit + }' $file } find_checkpoint_age() { @@ -567,6 +574,7 @@ format_innodb_status () { # 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 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 @@ -625,7 +633,7 @@ 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/percona-toolkit-mysqldump > /tmp/percona-toolkit + ' $file > /tmp/percona-toolkit head -n2 /tmp/percona-toolkit tail -n +3 /tmp/percona-toolkit | sort @@ -685,7 +693,7 @@ format_overall_db_stats () { print ""; } } - ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit + ' $file > /tmp/percona-toolkit head -n1 /tmp/percona-toolkit tail -n +2 /tmp/percona-toolkit | sort @@ -758,7 +766,7 @@ format_overall_db_stats () { print ""; } } - ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit + ' $file > /tmp/percona-toolkit head -n1 /tmp/percona-toolkit tail -n +2 /tmp/percona-toolkit | sort @@ -849,12 +857,11 @@ format_overall_db_stats () { print ""; } } - ' /tmp/percona-toolkit-mysqldump > /tmp/percona-toolkit + ' $file > /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 - } # ############################################################################## @@ -881,7 +888,7 @@ main() { 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/percona-toolkit - parse_mysqld_instances + parse_mysqld_instances /tmp/percona-toolkit # ######################################################################## # Fetch some basic info so we can start @@ -893,13 +900,13 @@ main() { exit 1 fi 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()' "$@")" + 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)" # ######################################################################## @@ -912,9 +919,9 @@ main() { get_mysql_version uptime="$(get_stat Uptime)" - mysql -ss -e "SELECT LEFT(NOW() - INTERVAL ${uptime} SECOND, 16)" "$@" \ + mysql "$@" -ss -e "SELECT LEFT(NOW() - INTERVAL ${uptime} SECOND, 16)" \ > /tmp/percona-toolkit - name_val Started "$(get_mysql_uptime)" + name_val Started "$(get_mysql_uptime /tmp/percona-toolkit)" name_val Databases "$($AP_GREP -c . /tmp/percona-toolkit-mysql-databases)" name_val Datadir "$(get_var datadir)" @@ -935,7 +942,7 @@ main() { # Processlist, sliced several different ways # ######################################################################## section Processlist - summarize_processlist + summarize_processlist /tmp/percona-toolkit-mysql-processlist # ######################################################################## # Queries and query plans @@ -943,7 +950,7 @@ main() { section "Status_Counters_(Wait_10_Seconds)" sleep 10 # TODO: gather this data in the same format as normal: stats, TS line - mysql -ss -e 'SHOW /*!50000 GLOBAL*/ STATUS' "$@" \ + mysql "$@" -ss -e 'SHOW /*!50000 GLOBAL*/ STATUS' \ | 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 @@ -970,7 +977,7 @@ main() { do echo "${var}" >> /tmp/percona-toolkit-noncounters done - format_status_variables | $AP_GREP -v -f /tmp/percona-toolkit-noncounters + format_status_variables /tmp/percona-toolkit | $AP_GREP -v -f /tmp/percona-toolkit-noncounters # ######################################################################## # Table cache @@ -1038,7 +1045,7 @@ main() { # that option to mysqldump, because when mysqldump checks for them, it # can take a long time, one table at a time. triggers="--skip-triggers" - trg=$(mysql -ss -e "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TRIGGERS" 2>/dev/null); + trg=$(mysql "$@" -ss -e "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TRIGGERS" 2>/dev/null); if [ "${res}" ]; then if [ "${res}" -gt 0 ]; then triggers="--triggers" @@ -1059,7 +1066,7 @@ main() { # might get partway through and then die, and the info is worth analyzing # anyway. if $AP_GREP 'CREATE TABLE' /tmp/percona-toolkit-mysqldump >/dev/null 2>&1; then - format_overall_db_stats + format_overall_db_stats /tmp/percona-toolkit-mysqldump else echo "Skipping schema analysis due to apparent error in dump file" rm -f /tmp/percona-toolkit-mysqldump @@ -1192,8 +1199,8 @@ main() { # Users & Security # ######################################################################## section Security - users="$(mysql -ss \ - -e 'SELECT COUNT(*), SUM(user=""), SUM(password=""), SUM(password NOT LIKE "*%") FROM mysql.user' "$@" 2>/dev/null \ + users="$(mysql "$@" -ss \ + -e 'SELECT COUNT(*), SUM(user=""), SUM(password=""), SUM(password NOT LIKE "*%") FROM mysql.user' 2>/dev/null \ | $AP_AWK '{printf "%d users, %d anon, %d w/o pw, %d old pw\n", $1, $2, $3, $4}')" name_val Users "${users}" name_val "Old Passwords" $(get_var old_passwords) @@ -1204,15 +1211,15 @@ main() { section Binary_Logging binlog=$(get_var log_bin) if [ "${binlog}" ]; then - mysql -ss -e 'SHOW MASTER LOGS' "$@" > /tmp/percona-toolkit 2>/dev/null - summarize_binlogs + mysql "$@" -ss -e 'SHOW MASTER LOGS' > /tmp/percona-toolkit 2>/dev/null + summarize_binlogs /tmp/percona-toolkit 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/percona-toolkit 2>/dev/null - format_binlog_filters + mysql "$@" -ss -e 'SHOW MASTER STATUS' > /tmp/percona-toolkit 2>/dev/null + format_binlog_filters /tmp/percona-toolkit fi # Replication: seconds behind, running, filters, skip_slave_start, skip_errors, @@ -1260,7 +1267,7 @@ main() { if [ -e "${cnf_file}" ]; then name_val "Config File" "${cnf_file}" cat "${cnf_file}" > /tmp/percona-toolkit - pretty_print_cnf_file + pretty_print_cnf_file /tmp/percona-toolkit else name_val "Config File" "Cannot autodetect or find, giving up" fi diff --git a/t/pt-mysql-summary/format_binlog_filters.sh b/t/pt-mysql-summary/format_binlog_filters.sh new file mode 100644 index 00000000..b1891e28 --- /dev/null +++ b/t/pt-mysql-summary/format_binlog_filters.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +TEST=1 + +cat < $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 diff --git a/t/pt-mysql-summary/overall_db_stats-01 b/t/pt-mysql-summary/format_overall_db_stats.sh old mode 100755 new mode 100644 similarity index 66% rename from t/pt-mysql-summary/overall_db_stats-01 rename to t/pt-mysql-summary/format_overall_db_stats.sh index c4ee7f0c..abee9223 --- a/t/pt-mysql-summary/overall_db_stats-01 +++ b/t/pt-mysql-summary/format_overall_db_stats.sh @@ -1,7 +1,8 @@ #!/bin/bash -#format_overall_db_stats -cat < $1 +TESTS=2 + +cat < $TMPDIR/expected Database Tables Views SPs Trigs Funcs FKs Partn mysql 17 @@ -29,5 +30,31 @@ cat < $1 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 -cp samples/mysql-schema-001.txt /tmp/percona-toolkit-mysqldump + +cat < $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 diff --git a/t/pt-mysql-summary/format_status_variables-01 b/t/pt-mysql-summary/format_status_variables.sh old mode 100755 new mode 100644 similarity index 97% rename from t/pt-mysql-summary/format_status_variables-01 rename to t/pt-mysql-summary/format_status_variables.sh index fef27456..8ddf95bb --- a/t/pt-mysql-summary/format_status_variables-01 +++ b/t/pt-mysql-summary/format_status_variables.sh @@ -1,7 +1,8 @@ #!/bin/bash -#format_status_variables -cat < $1 +TESTS=1 + +cat < $TMPDIR/expected Variable Per day Per second 5 secs Bytes_received 8000000 100 Bytes_sent 35000000 400 @@ -90,4 +91,6 @@ Uptime 90000 1 1 Uptime_since_flush_status 90000 1 EOF -join samples/mysql-status-00{1,2}.txt > /tmp/percona-toolkit +join samples/mysql-status-00{1,2}.txt > $TMPDIR/in +format_status_variables $TMPDIR/in > $TMPDIR/got +no_diff $TMPDIR/got $TMPDIR/expected diff --git a/t/pt-mysql-summary/get-mysql-tz b/t/pt-mysql-summary/get-mysql-tz deleted file mode 100755 index 26556770..00000000 --- a/t/pt-mysql-summary/get-mysql-tz +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -#get_mysql_timezone - -echo EDT > $1 - -cp samples/mysql-variables-001.txt /tmp/percona-toolkit-mysql-variables diff --git a/t/pt-mysql-summary/get-mysql-uptime b/t/pt-mysql-summary/get-mysql-uptime deleted file mode 100755 index b70be0a3..00000000 --- a/t/pt-mysql-summary/get-mysql-uptime +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -#get_mysql_uptime - -cat < $1 -2010-05-27 11:38 (up 0+02:08:52) -EOF - -cp samples/mysql-status-001.txt /tmp/percona-toolkit-mysql-status -echo "2010-05-27 11:38" > /tmp/percona-toolkit diff --git a/t/pt-mysql-summary/get-mysql-version b/t/pt-mysql-summary/get-mysql-version deleted file mode 100755 index 04814090..00000000 --- a/t/pt-mysql-summary/get-mysql-version +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -#get_mysql_version - -cat < $1 - Version | 5.0.51a-24+lenny2 (Debian) - Built On | debian-linux-gnu i486 -EOF - -cp samples/mysql-variables-001.txt /tmp/percona-toolkit-mysql-variables diff --git a/t/pt-mysql-summary/get_mysql_info.sh b/t/pt-mysql-summary/get_mysql_info.sh new file mode 100644 index 00000000..0accdf52 --- /dev/null +++ b/t/pt-mysql-summary/get_mysql_info.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +TESTS=3 + +TEST_NAME="get_mysql_timezone" +cp samples/mysql-variables-001.txt /tmp/percona-toolkit-mysql-variables +is $(get_mysql_timezone) "EDT" + +TEST_NAME="get_mysql_uptime" +cat < $TMPDIR/expected +2010-05-27 11:38 (up 0+02:08:52) +EOF +cp samples/mysql-status-001.txt /tmp/percona-toolkit-mysql-status +echo "2010-05-27 11:38" > $TMPDIR/in +get_mysql_uptime $TMPDIR/in > $TMPDIR/got +no_diff $TMPDIR/got $TMPDIR/expected + +TEST_NAME="get_mysql_version" +cat < $TMPDIR/expected + Version | 5.0.51a-24+lenny2 (Debian) + Built On | debian-linux-gnu i486 +EOF +cp samples/mysql-variables-001.txt /tmp/percona-toolkit-mysql-variables +get_mysql_version > $TMPDIR/got +no_diff $TMPDIR/got $TMPDIR/expected diff --git a/t/pt-mysql-summary/overall_db_stats-02 b/t/pt-mysql-summary/overall_db_stats-02 deleted file mode 100755 index 7e46f901..00000000 --- a/t/pt-mysql-summary/overall_db_stats-02 +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -#format_overall_db_stats - -cat < $1 - - 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 - -cp samples/mysql-schema-002.txt /tmp/percona-toolkit-mysqldump diff --git a/t/pt-mysql-summary/parse-master-status-01 b/t/pt-mysql-summary/parse-master-status-01 deleted file mode 100755 index 4c7ac0f6..00000000 --- a/t/pt-mysql-summary/parse-master-status-01 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -#format_binlog_filters - -cat < $1 - binlog_do_db | foo - binlog_ignore_db | mysql,test -EOF - -cp samples/mysql-show-master-status-001.txt /tmp/percona-toolkit diff --git a/t/pt-mysql-summary/parse-mysqld-instances-01 b/t/pt-mysql-summary/parse-mysqld-instances-01 deleted file mode 100755 index 2fc73749..00000000 --- a/t/pt-mysql-summary/parse-mysqld-instances-01 +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -#parse_mysqld_instances - -cat < $1 - Port Data Directory 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 - -cp samples/ps-mysqld-001.txt /tmp/percona-toolkit diff --git a/t/pt-mysql-summary/parse-mysqld-instances-02 b/t/pt-mysql-summary/parse-mysqld-instances-02 deleted file mode 100755 index f03d651b..00000000 --- a/t/pt-mysql-summary/parse-mysqld-instances-02 +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -#parse_mysqld_instances - -cat < $1 - Port Data Directory Socket - ===== ========================== ====== - /var/lib/mysql /var/lib/mysql/mysql.sock -EOF - -cp samples/ps-mysqld-002.txt /tmp/percona-toolkit diff --git a/t/pt-mysql-summary/parse-mysqld-instances-03 b/t/pt-mysql-summary/parse-mysqld-instances-03 deleted file mode 100755 index 83848c1d..00000000 --- a/t/pt-mysql-summary/parse-mysqld-instances-03 +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -#parse_mysqld_instances - -cat < $1 - Port Data Directory Socket - ===== ========================== ====== - 3306 /mnt/data-store/mysql/data /tmp/mysql.sock -EOF - -cp samples/ps-mysqld-003.txt /tmp/percona-toolkit diff --git a/t/pt-mysql-summary/parse-mysqld-instances-04 b/t/pt-mysql-summary/parse-mysqld-instances-04 deleted file mode 100755 index b6581f99..00000000 --- a/t/pt-mysql-summary/parse-mysqld-instances-04 +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -#parse_mysqld_instances - -cat < $1 - Port Data Directory Socket - ===== ========================== ====== - /var/db/mysql -EOF - -cat < $2 -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 diff --git a/t/pt-mysql-summary/parse_mysqld_instances.sh b/t/pt-mysql-summary/parse_mysqld_instances.sh new file mode 100644 index 00000000..4e6fbd2f --- /dev/null +++ b/t/pt-mysql-summary/parse_mysqld_instances.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +TESTS=4 + +TEST_NAME="ps-mysqld-001.txt" +cat < $TMPDIR/expected + Port Data Directory 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 < $TMPDIR/expected + Port Data Directory 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 < $TMPDIR/expected + Port Data Directory 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 < $TMPDIR/expected + Port Data Directory Socket + ===== ========================== ====== + /var/db/mysql +EOF + +cat < $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 diff --git a/t/pt-mysql-summary/pretty-print-my-cnf-01 b/t/pt-mysql-summary/pretty_print_cnf_file.sh old mode 100755 new mode 100644 similarity index 89% rename from t/pt-mysql-summary/pretty-print-my-cnf-01 rename to t/pt-mysql-summary/pretty_print_cnf_file.sh index a9bb645b..5a4bec30 --- a/t/pt-mysql-summary/pretty-print-my-cnf-01 +++ b/t/pt-mysql-summary/pretty_print_cnf_file.sh @@ -1,7 +1,8 @@ #!/bin/bash -#pretty_print_cnf_file -cat < $1 +TESTS=1 + +cat < $TMPDIR/expected [mysqld] datadir = /mnt/data/mysql @@ -34,4 +35,5 @@ pid-file = /var/run/mysqld/mysqld.pid target-dir = /data/backup EOF -cp samples/my.cnf-001.txt /tmp/percona-toolkit +pretty_print_cnf_file samples/my.cnf-001.txt > $TMPDIR/got +no_diff $TMPDIR/got $TMPDIR/expected diff --git a/t/pt-mysql-summary/summarize-binlogs-01 b/t/pt-mysql-summary/summarize-binlogs-01 deleted file mode 100755 index 6b402f04..00000000 --- a/t/pt-mysql-summary/summarize-binlogs-01 +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -#summarize_binlogs - -cat < $1 - Binlogs | 20 - Zero-Sized | 3 - Total Size | 6.5G -EOF - -cp samples/mysql-master-logs-001.txt /tmp/percona-toolkit diff --git a/t/pt-mysql-summary/summarize_binlogs.sh b/t/pt-mysql-summary/summarize_binlogs.sh new file mode 100644 index 00000000..e1a48b66 --- /dev/null +++ b/t/pt-mysql-summary/summarize_binlogs.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +TESTS=1 + +cat < $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 diff --git a/t/pt-mysql-summary/parse-processlist-01 b/t/pt-mysql-summary/summarize_processlist.sh old mode 100755 new mode 100644 similarity index 96% rename from t/pt-mysql-summary/parse-processlist-01 rename to t/pt-mysql-summary/summarize_processlist.sh index 88cfcc74..abcb8de3 --- a/t/pt-mysql-summary/parse-processlist-01 +++ b/t/pt-mysql-summary/summarize_processlist.sh @@ -1,7 +1,8 @@ #!/bin/bash -#summarize_processlist -cat < $1 +TESTS=1 + +cat < $TMPDIR/expected Command COUNT(*) Working SUM(Time) MAX(Time) ------------------------------ -------- ------- --------- --------- @@ -58,4 +59,5 @@ cat < $1 EOF -cp samples/processlist-001.txt /tmp/percona-toolkit-mysql-processlist +summarize_processlist samples/processlist-001.txt > $TMPDIR/got +no_diff $TMPDIR/got $TMPDIR/expected