From 58d1d2c3b4f9b91bb0ee4638c4c93a95ea4aeb2e Mon Sep 17 00:00:00 2001 From: Fernando Ipar Date: Mon, 9 Oct 2017 22:26:46 -0300 Subject: [PATCH 1/8] Added skel for ndb status collector --- bin/pt-mysql-summary | 71 ++++++++-------------------------- lib/bash/collect_mysql_info.sh | 5 +++ lib/bash/report_mysql_info.sh | 8 ++++ 3 files changed, 29 insertions(+), 55 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index df52ea59..fd51f7e1 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 } @@ -1026,6 +1030,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" @@ -1374,7 +1379,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) } @@ -1387,6 +1392,7 @@ pretty_print_cnf_file () { } + find_checkpoint_age() { local file="$1" awk ' @@ -1576,6 +1582,13 @@ format_innodb_status () { fi } +format_ndb_status() { + local file=$1 + + [ -e "$file" ] || return + cat "$file" +} + format_overall_db_stats () { local file="$1" local tmpfile="$PT_TMPDIR/format_overall_db_stats.tmp" @@ -2097,19 +2110,6 @@ 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" @@ -2162,41 +2162,6 @@ 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) | 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" @@ -2210,8 +2175,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")" @@ -2391,9 +2354,9 @@ report_mysql_summary () { section "InnoDB" local have_innodb="$(get_var "have_innodb" "$dir/mysql-variables")" - local innodb_version="$(get_var "innodb_version" "$dir/mysql-variables")" - if [ "${have_innodb}" = "YES" ] || [ -n "${innodb_version}" ]; then + if [ "${have_innodb}" = "YES" ]; then section_innodb "$dir/mysql-variables" "$dir/mysql-status" + if [ -s "$dir/innodb-status" ]; then format_innodb_status "$dir/innodb-status" fi @@ -2434,8 +2397,6 @@ report_mysql_summary () { name_val "Config File" "Cannot autodetect or find, giving up" fi - 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..c1df757d 100644 --- a/lib/bash/collect_mysql_info.sh +++ b/lib/bash/collect_mysql_info.sh @@ -108,6 +108,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 } @@ -223,6 +227,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..02839527 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 + # at the time being, just cat the file. + cat "$file" +} + # 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. From a77b68ed73f46c8bf7c957acc4861d927ea4c4e0 Mon Sep 17 00:00:00 2001 From: Fernando Ipar Date: Tue, 10 Oct 2017 10:43:58 -0300 Subject: [PATCH 2/8] Improved formatting of the ndb status a bit --- bin/pt-mysql-summary | 2 +- lib/bash/report_mysql_info.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index fd51f7e1..b165e805 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -1586,7 +1586,7 @@ format_ndb_status() { local file=$1 [ -e "$file" ] || return - cat "$file" + egrep '^[ \t]*Name:|[ \t]*Status:' ndb_status.txt|sed 's/^[ \t]*//g'|while read line; do echo $line; echo $line | grep '^Status:'>/dev/null && echo ; done } format_overall_db_stats () { diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index 02839527..9bb6dfb6 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -561,8 +561,8 @@ format_ndb_status() { local file=$1 [ -e "$file" ] || return - # at the time being, just cat the file. - cat "$file" + # We could use "& \n" but that does not seem to work on bsd sed. + egrep '^[ \t]*Name:|[ \t]*Status:' ndb_status.txt|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 From 5b9ecef04c6ae1540ea90099c01474bd586ed63f Mon Sep 17 00:00:00 2001 From: Fernando Ipar Date: Tue, 10 Oct 2017 10:50:26 -0300 Subject: [PATCH 3/8] printing the ndb section --- bin/pt-mysql-summary | 5 +++++ lib/bash/report_mysql_info.sh | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index b165e805..f4230f7d 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -2362,6 +2362,11 @@ report_mysql_summary () { fi 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" diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index 9bb6dfb6..0a6eb72c 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -1418,6 +1418,14 @@ report_mysql_summary () { fi fi + # ######################################################################## + # NDB + # ######################################################################## + if [ -s "$dir/ndb-status" ]; then + section "NDB" + format_ndb_status "$dir/ndb-status" + fi + # ######################################################################## # MyISAM # ######################################################################## From e90b3a77f50835812fef305c336f3293197144b2 Mon Sep 17 00:00:00 2001 From: Fernando Ipar Date: Tue, 10 Oct 2017 10:52:11 -0300 Subject: [PATCH 4/8] removed accidentally hardcoded file name --- bin/pt-mysql-summary | 2 +- lib/bash/report_mysql_info.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index f4230f7d..8364e820 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -1586,7 +1586,7 @@ format_ndb_status() { local file=$1 [ -e "$file" ] || return - egrep '^[ \t]*Name:|[ \t]*Status:' ndb_status.txt|sed 's/^[ \t]*//g'|while read line; do echo $line; echo $line | grep '^Status:'>/dev/null && echo ; done + 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 () { diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index 0a6eb72c..a2f5d518 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -562,7 +562,7 @@ format_ndb_status() { [ -e "$file" ] || return # We could use "& \n" but that does not seem to work on bsd sed. - egrep '^[ \t]*Name:|[ \t]*Status:' ndb_status.txt|sed 's/^[ \t]*//g'|while read line; do echo $line; echo $line | grep '^Status:'>/dev/null && echo ; done + 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 From 48e85c8ca371d7dfde2c2d27a59120e10c1388bd Mon Sep 17 00:00:00 2001 From: Fernando Ipar Date: Mon, 16 Oct 2017 14:25:34 -0300 Subject: [PATCH 5/8] reverting changes to pt-mysql-summary as update-modules is changing other things beyond the ndb collection --- bin/pt-mysql-summary | 76 ++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 8364e820..df52ea59 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -921,10 +921,6 @@ 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 } @@ -1030,7 +1026,6 @@ 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" @@ -1379,7 +1374,7 @@ pretty_print_cnf_file () { perl -n -l -e ' my $line = $_; - if ( $line =~ /^\s*[a-zA-Z[]/ ) { + if ( $line =~ /^[ \t]*[a-zA-Z[]/ ) { if ( $line=~/\s*(.*?)\s*=\s*(.*)\s*$/ ) { printf("%-35s = %s\n", $1, $2) } @@ -1392,7 +1387,6 @@ pretty_print_cnf_file () { } - find_checkpoint_age() { local file="$1" awk ' @@ -1582,13 +1576,6 @@ 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" @@ -2110,6 +2097,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" @@ -2162,6 +2162,41 @@ 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) | 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" @@ -2175,6 +2210,8 @@ 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")" @@ -2354,19 +2391,14 @@ 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 format_innodb_status "$dir/innodb-status" fi 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" @@ -2402,6 +2434,8 @@ report_mysql_summary () { name_val "Config File" "Cannot autodetect or find, giving up" fi + section "Memory management library" + report_jemalloc_enabled section "The End" } From 6e96a1123c8b7365851c5475a748d5683954c599 Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Tue, 3 Apr 2018 16:37:40 -0300 Subject: [PATCH 6/8] Updated bash libraries --- bin/pt-mysql-summary | 26 +++++++---- lib/bash/report_mysql_info.sh | 86 ++++++++++++++++++++++++++++++++++- 2 files changed, 103 insertions(+), 9 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 5814e487..5d55d1b5 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -1377,7 +1377,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 +1390,7 @@ pretty_print_cnf_file () { } + find_checkpoint_age() { local file="$1" awk ' @@ -1579,6 +1580,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 +2200,6 @@ parse_wsrep_provider_options () { } report_jemalloc_enabled() { - local JEMALLOC_STATUS='' local GENERAL_JEMALLOC_STATUS=0 local JEMALLOC_LOCATION='' @@ -2209,8 +2216,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 +2245,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 +2312,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 +2427,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 +2439,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 +2481,7 @@ report_mysql_summary () { section "Memory management library" report_jemalloc_enabled + section "The End" } diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index a2f5d518..8d2f3b84 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -996,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" @@ -1121,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" @@ -1173,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" @@ -1190,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 # ######################################################################## @@ -1410,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 @@ -1418,6 +1493,12 @@ 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 # ######################################################################## @@ -1478,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" } From f6c01fc5bf16abb39af5a934522cef11b5edcf4a Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Wed, 4 Apr 2018 09:26:02 -0300 Subject: [PATCH 7/8] PT-1526 Add ndb status to pt-mysql-summary --- bin/pt-mysql-summary | 6 ++++++ lib/bash/collect_mysql_info.sh | 4 ++++ t/pt-mysql-summary/pt-mysql-summary.t | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 5d55d1b5..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" diff --git a/lib/bash/collect_mysql_info.sh b/lib/bash/collect_mysql_info.sh index c1df757d..39d5275c 100644 --- a/lib/bash/collect_mysql_info.sh +++ b/lib/bash/collect_mysql_info.sh @@ -118,6 +118,10 @@ collect_mysql_processlist () { 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 () { 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`); From a7577dc42004ee516ebcec3923b6b91ff3af8273 Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Wed, 4 Apr 2018 09:31:47 -0300 Subject: [PATCH 8/8] PT-1526 updated changelog) --- Changelog | 1 + 1 file changed, 1 insertion(+) 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)