diff --git a/Changelog b/Changelog index 208dd0e2..2b8b9505 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ Changelog for Percona Toolkit v3.0.9 + * Feature PT-1526 : Add ndb status to pt-mysql-summary (Thanks Fernando Ipar) * Feature PT-1509 : Only set binlog_format when necessary (Thanks Moritz Lenz) * Feature PT-1508 : Adding --read-only-interval flag, and read-only check on wake-up (Thanks Shlomi Noach) * Improvement PT-1507 : pt-summary does not reliably read in the transparent huge pages setting (Thanks Nick Veenhof) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 5814e487..1439ea16 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -921,6 +921,10 @@ collect_mysql_innodb_status () { $CMD_MYSQL $EXT_ARGV -ssE -e 'SHOW /*!50000 ENGINE*/ INNODB STATUS' 2>/dev/null } +collect_mysql_ndb_status () { + $CMD_MYSQL $EXT_ARGV -ssE -e 'show /*!50000 ENGINE*/ NDB STATUS' 2>/dev/null +} + collect_mysql_processlist () { $CMD_MYSQL $EXT_ARGV -ssE -e 'SHOW FULL PROCESSLIST' 2>/dev/null } @@ -930,6 +934,7 @@ collect_mysql_users () { if [ "$?" -ne 0 ]; then $CMD_MYSQL $EXT_ARGV -ss -e 'SELECT COUNT(*), SUM(user=""), SUM(authentication_string=""), SUM(authentication_string NOT LIKE "*%") FROM mysql.user' 2>/dev/null fi + } collect_mysql_show_slave_hosts () { @@ -1029,6 +1034,7 @@ collect_mysql_info () { collect_mysql_plugins > "$dir/mysql-plugins" collect_mysql_slave_status > "$dir/mysql-slave" collect_mysql_innodb_status > "$dir/innodb-status" + collect_mysql_ndb_status > "$dir/ndb-status" collect_mysql_processlist > "$dir/mysql-processlist" collect_mysql_users > "$dir/mysql-users" @@ -1377,7 +1383,7 @@ pretty_print_cnf_file () { perl -n -l -e ' my $line = $_; - if ( $line =~ /^[ \t]*[a-zA-Z[]/ ) { + if ( $line =~ /^\s*[a-zA-Z[]/ ) { if ( $line=~/\s*(.*?)\s*=\s*(.*)\s*$/ ) { printf("%-35s = %s\n", $1, $2) } @@ -1390,6 +1396,7 @@ pretty_print_cnf_file () { } + find_checkpoint_age() { local file="$1" awk ' @@ -1579,6 +1586,13 @@ format_innodb_status () { fi } +format_ndb_status() { + local file=$1 + + [ -e "$file" ] || return + egrep '^[ \t]*Name:|[ \t]*Status:' $file|sed 's/^[ \t]*//g'|while read line; do echo $line; echo $line | grep '^Status:'>/dev/null && echo ; done +} + format_overall_db_stats () { local file="$1" local tmpfile="$PT_TMPDIR/format_overall_db_stats.tmp" @@ -2192,7 +2206,6 @@ parse_wsrep_provider_options () { } report_jemalloc_enabled() { - local JEMALLOC_STATUS='' local GENERAL_JEMALLOC_STATUS=0 local JEMALLOC_LOCATION='' @@ -2209,8 +2222,6 @@ report_jemalloc_enabled() { done if [ $GENERAL_JEMALLOC_STATUS = 1 ]; then - # Check location for libjemalloc.so.1 - #for libjemall in "${SCRIPT_PWD}/lib/mysql" "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do for libjemall in "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do if [ -r "$libjemall/libjemalloc.so.1" ]; then JEMALLOC_LOCATION="$libjemall/libjemalloc.so.1" @@ -2240,7 +2251,6 @@ report_mysql_summary () { section_mysqld "$dir/mysqld-executables" "$dir/mysql-variables" section_slave_hosts "$dir/mysql-slave-hosts" - local user="$(get_var "pt-summary-internal-user" "$dir/mysql-variables")" local port="$(get_var port "$dir/mysql-variables")" local now="$(get_var "pt-summary-internal-now" "$dir/mysql-variables")" @@ -2308,8 +2318,7 @@ report_mysql_summary () { section "Plugins" name_val "InnoDB compression" "$(get_plugin_status "$dir/mysql-plugins" "INNODB_CMP")" - local has_query_cache=$(get_var have_query_cache "$dir/mysql-variables") - if [ "$has_query_cache" = 'YES' ]; then + if [ "$(get_var have_query_cache "$dir/mysql-variables")" ]; then section "Query cache" local query_cache_size=$(get_var query_cache_size "$dir/mysql-variables") local used=$(( ${query_cache_size} - $(get_var Qcache_free_memory "$dir/mysql-status") )) @@ -2424,10 +2433,11 @@ report_mysql_summary () { local innodb_version="$(get_var "innodb_version" "$dir/mysql-variables")" if [ "${have_innodb}" = "YES" ] || [ -n "${innodb_version}" ]; then section_innodb "$dir/mysql-variables" "$dir/mysql-status" + if [ -s "$dir/innodb-status" ]; then format_innodb_status "$dir/innodb-status" fi - fi + fi local has_rocksdb=$($CMD_MYSQL $EXT_ARGV -ss -e 'SHOW ENGINES' 2>/dev/null | grep -i 'rocksdb') if [ ! -z "$has_rocksdb" ]; then @@ -2435,6 +2445,11 @@ report_mysql_summary () { section_rocksdb "$dir/mysql-variables" "$dir/mysql-status" fi + if [ -s "$dir/ndb-status" ]; then + section "NDB" + format_ndb_status "$dir/ndb-status" + fi + section "MyISAM" section_myisam "$dir/mysql-variables" "$dir/mysql-status" @@ -2472,6 +2487,7 @@ report_mysql_summary () { section "Memory management library" report_jemalloc_enabled + section "The End" } diff --git a/lib/bash/collect_mysql_info.sh b/lib/bash/collect_mysql_info.sh index 92558be7..39d5275c 100644 --- a/lib/bash/collect_mysql_info.sh +++ b/lib/bash/collect_mysql_info.sh @@ -108,12 +108,20 @@ collect_mysql_innodb_status () { $CMD_MYSQL $EXT_ARGV -ssE -e 'SHOW /*!50000 ENGINE*/ INNODB STATUS' 2>/dev/null } +collect_mysql_ndb_status () { + $CMD_MYSQL $EXT_ARGV -ssE -e 'show /*!50000 ENGINE*/ NDB STATUS' 2>/dev/null +} + collect_mysql_processlist () { $CMD_MYSQL $EXT_ARGV -ssE -e 'SHOW FULL PROCESSLIST' 2>/dev/null } collect_mysql_users () { $CMD_MYSQL $EXT_ARGV -ss -e 'SELECT COUNT(*), SUM(user=""), SUM(password=""), SUM(password NOT LIKE "*%") FROM mysql.user' 2>/dev/null + if [ "$?" -ne 0 ]; then + $CMD_MYSQL $EXT_ARGV -ss -e 'SELECT COUNT(*), SUM(user=""), SUM(authentication_string=""), SUM(authentication_string NOT LIKE "*%") FROM mysql.user' 2>/dev/null + fi + } collect_mysql_show_slave_hosts () { @@ -223,6 +231,7 @@ collect_mysql_info () { collect_mysql_plugins > "$dir/mysql-plugins" collect_mysql_slave_status > "$dir/mysql-slave" collect_mysql_innodb_status > "$dir/innodb-status" + collect_mysql_ndb_status > "$dir/ndb-status" collect_mysql_processlist > "$dir/mysql-processlist" collect_mysql_users > "$dir/mysql-users" diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index 289693f1..8d2f3b84 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -557,6 +557,14 @@ format_innodb_status () { fi } +format_ndb_status() { + local file=$1 + + [ -e "$file" ] || return + # We could use "& \n" but that does not seem to work on bsd sed. + egrep '^[ \t]*Name:|[ \t]*Status:' $file|sed 's/^[ \t]*//g'|while read line; do echo $line; echo $line | grep '^Status:'>/dev/null && echo ; done +} + # Summarizes per-database statistics for a bunch of different things: count of # tables, views, etc. $1 is the file name. $2 is the database name; if none, # then there should be multiple databases. @@ -988,6 +996,32 @@ section_innodb () { "$(get_var innodb_adaptive_checkpoint "$variables_file")" } +section_rocksdb () { + local variables_file="$1" + local status_file="$2" + + local NAME_VAL_LEN=32 + + [ -e "$variables_file" -a -e "$status_file" ] || return + + name_val "Block Cache Size" "$(shorten $(get_var rocksdb_block_cache_size "$variables_file") 0)" + name_val "Block Size" "$(shorten $(get_var rocksdb_block_size "$variables_file") 0)" + name_val "Bytes Per Sync" "$(shorten $(get_var rocksdb_bytes_per_sync "$variables_file") 0)" + name_val "Compaction Seq Deletes " "$(shorten $(get_var rocksdb_compaction_sequential_deletes "$variables_file") 0)" + name_val "Compaction Seq Deletes Count SD" "$(get_var rocksdb_compaction_sequential_deletes_count_sd "$variables_file")" + name_val "Compaction Seq Deletes Window" "$(shorten $(get_var rocksdb_compaction_sequential_deletes_window "$variables_file") 0)" + name_val "Default CF Options" "$(get_var rocksdb_default_cf_options "$variables_file")" + name_val "Max Background Jobs" "$(shorten $(get_var rocksdb_max_background_jobs "$variables_file") 0)" + name_val "Max Block Cache Size" "$(shorten $(get_var rocksdb_max_block_cache_size "$variables_file") 0)" + name_val "Max Block Size" "$(shorten $(get_var rocksdb_max_block_size "$variables_file") 0)" + name_val "Max Open Files" "$(shorten $(get_var rocksdb_max_open_files "$variables_file") 0)" + name_val "Max Total Wal Size" "$(shorten $(get_var rocksdb_max_total_wal_size "$variables_file") 0)" + name_val "Rate Limiter Bytes Per Second" "$(shorten $(get_var rocksdb_rate_limiter_bytes_per_sec "$variables_file") 0)" + name_val "Rate Limiter Bytes Per Sync" "$(shorten $(get_var rocksdb_bytes_per_sync "$variables_file") 0)" + name_val "Rate Limiter Wal Bytes Per Sync" "$(shorten $(get_var rocksdb_wal_bytes_per_sync "$variables_file") 0)" + name_val "Table Cache NumHardBits" "$(shorten $(get_var rocksdb_table_cache_numshardbits "$variables_file") 0)" + name_val "Wal Bytes per Sync" "$(shorten $(get_var rocksdb_wal_bytes_per_sync "$variables_file") 0)" +} section_noteworthy_variables () { local file="$1" @@ -1113,6 +1147,19 @@ section_mysqld () { done < "$executables_file" } +section_slave_hosts () { + local slave_hosts_file="$1" + + [ -e "$slave_hosts_file" ] || return + + section "Slave Hosts" + if [ -s "$slave_hosts_file" ]; then + cat "$slave_hosts_file" + else + echo "No slaves found" + fi +} + section_mysql_files () { local variables_file="$1" @@ -1165,6 +1212,40 @@ parse_wsrep_provider_options () { ' "$looking_for" } +report_jemalloc_enabled() { + local JEMALLOC_STATUS='' + local GENERAL_JEMALLOC_STATUS=0 + local JEMALLOC_LOCATION='' + + for PID in $(pidof mysqld); do + grep -qc jemalloc /proc/${PID}/environ || ldd $(which mysqld) 2>/dev/null | grep -qc jemalloc + JEMALLOC_STATUS=$? + if [ $JEMALLOC_STATUS = 1 ]; then + echo "jemalloc is not enabled in MySQL config for process with ID ${PID}" + else + echo "jemalloc enabled in MySQL config for process with ID ${PID}" + GENERAL_JEMALLOC_STATUS=1 + fi + done + + if [ $GENERAL_JEMALLOC_STATUS = 1 ]; then + # Check location for libjemalloc.so.1 + #for libjemall in "${SCRIPT_PWD}/lib/mysql" "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do + for libjemall in "/usr/lib64" "/usr/lib/x86_64-linux-gnu" "/usr/lib"; do + if [ -r "$libjemall/libjemalloc.so.1" ]; then + JEMALLOC_LOCATION="$libjemall/libjemalloc.so.1" + break + fi + done + if [ -z $JEMALLOC_LOCATION ]; then + echo "Jemalloc library not found" + else + echo "Using jemalloc from $JEMALLOC_LOCATION" + fi + fi + +} + report_mysql_summary () { local dir="$1" @@ -1182,6 +1263,7 @@ report_mysql_summary () { section_mysqld "$dir/mysqld-executables" "$dir/mysql-variables" + section_slave_hosts "$dir/mysql-slave-hosts" # ######################################################################## # General date, hostname, etc # ######################################################################## @@ -1402,7 +1484,8 @@ report_mysql_summary () { # ######################################################################## section "InnoDB" local have_innodb="$(get_var "have_innodb" "$dir/mysql-variables")" - if [ "${have_innodb}" = "YES" ]; then + local innodb_version="$(get_var "innodb_version" "$dir/mysql-variables")" + if [ "${have_innodb}" = "YES" ] || [ -n "${innodb_version}" ]; then section_innodb "$dir/mysql-variables" "$dir/mysql-status" if [ -s "$dir/innodb-status" ]; then @@ -1410,6 +1493,20 @@ report_mysql_summary () { fi fi + local has_rocksdb=$($CMD_MYSQL $EXT_ARGV -ss -e 'SHOW ENGINES' 2>/dev/null | grep -i 'rocksdb') + if [ ! -z "$has_rocksdb" ]; then + section "RocksDB" + section_rocksdb "$dir/mysql-variables" "$dir/mysql-status" + fi + + # ######################################################################## + # NDB + # ######################################################################## + if [ -s "$dir/ndb-status" ]; then + section "NDB" + format_ndb_status "$dir/ndb-status" + fi + # ######################################################################## # MyISAM # ######################################################################## @@ -1462,6 +1559,9 @@ report_mysql_summary () { name_val "Config File" "Cannot autodetect or find, giving up" fi + section "Memory management library" + report_jemalloc_enabled + # Make sure that we signal the end of the tool's output. section "The End" } diff --git a/t/pt-mysql-summary/pt-mysql-summary.t b/t/pt-mysql-summary/pt-mysql-summary.t index 3ea61c8a..9d7b7177 100644 --- a/t/pt-mysql-summary/pt-mysql-summary.t +++ b/t/pt-mysql-summary/pt-mysql-summary.t @@ -42,7 +42,7 @@ ok( my @files = glob("$dir/*"); my $n_files = scalar @files; ok( - $n_files >= 15 && $n_files <= 16, + $n_files >= 15 && $n_files <= 17, "And leaves all files in there" ) or diag($n_files, `ls -l $dir`);