diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 10f0ea56..df52ea59 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -929,6 +929,10 @@ 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 } +collect_mysql_show_slave_hosts () { + $CMD_MYSQL $EXT_ARGV -ssE -e 'SHOW SLAVE HOSTS' 2>/dev/null +} + collect_master_logs_status () { local master_logs_file="$1" local master_status_file="$2" @@ -1027,6 +1031,7 @@ collect_mysql_info () { collect_mysqld_instances "$dir/mysql-variables" > "$dir/mysqld-instances" collect_mysqld_executables "$dir/mysqld-instances" > "$dir/mysqld-executables" + collect_mysql_show_slave_hosts "$dir/mysql-slave-hosts" > "$dir/mysql-slave-hosts" local binlog="$(get_var log_bin "$dir/mysql-variables")" if [ "${binlog}" ]; then @@ -2092,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" @@ -2192,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")" diff --git a/lib/bash/collect_mysql_info.sh b/lib/bash/collect_mysql_info.sh index dd131633..92558be7 100644 --- a/lib/bash/collect_mysql_info.sh +++ b/lib/bash/collect_mysql_info.sh @@ -116,6 +116,10 @@ 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 } +collect_mysql_show_slave_hosts () { + $CMD_MYSQL $EXT_ARGV -ssE -e 'SHOW SLAVE HOSTS' 2>/dev/null +} + collect_master_logs_status () { local master_logs_file="$1" local master_status_file="$2" @@ -224,6 +228,7 @@ collect_mysql_info () { collect_mysqld_instances "$dir/mysql-variables" > "$dir/mysqld-instances" collect_mysqld_executables "$dir/mysqld-instances" > "$dir/mysqld-executables" + collect_mysql_show_slave_hosts "$dir/mysql-slave-hosts" > "$dir/mysql-slave-hosts" local binlog="$(get_var log_bin "$dir/mysql-variables")" if [ "${binlog}" ]; then