mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 17:04:00 +00:00
PT-1525 Added support for roles in mysql-summary
This commit is contained in:
@@ -117,11 +117,17 @@ collect_mysql_processlist () {
|
||||
}
|
||||
|
||||
collect_mysql_users () {
|
||||
# The where clause has been added to skip listing MySQL 8+ roles as users.
|
||||
# ROLES are locked accounts, without passwords and expired.
|
||||
$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
|
||||
$CMD_MYSQL $EXT_ARGV -ss -e 'SELECT COUNT(*), SUM(user=""), SUM(authentication_string=""), SUM(authentication_string NOT LIKE "*%") FROM mysql.user WHERE account_locked <> "Y" AND password_expired <> "Y" AND authentication_string <> ""' 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
collect_mysql_roles () {
|
||||
QUERY="SELECT DISTINCT User 'Role Name', if(from_user is NULL,0, 1) Active FROM mysql.user LEFT JOIN mysql.role_edges ON from_user=user WHERE account_locked='Y' AND password_expired='Y' AND authentication_string=''\G"
|
||||
$CMD_MYSQL $EXT_ARGV -ss -e "$QUERY" 2>/dev/null
|
||||
}
|
||||
|
||||
collect_mysql_show_slave_hosts () {
|
||||
@@ -234,6 +240,7 @@ collect_mysql_info () {
|
||||
collect_mysql_ndb_status > "$dir/ndb-status"
|
||||
collect_mysql_processlist > "$dir/mysql-processlist"
|
||||
collect_mysql_users > "$dir/mysql-users"
|
||||
collect_mysql_roles > "$dir/mysql-roles"
|
||||
|
||||
collect_mysqld_instances "$dir/mysql-variables" > "$dir/mysqld-instances"
|
||||
collect_mysqld_executables "$dir/mysqld-instances" > "$dir/mysqld-executables"
|
||||
|
@@ -565,6 +565,12 @@ format_ndb_status() {
|
||||
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_mysql_roles() {
|
||||
local file=$1
|
||||
[ -e "$file" ] || return
|
||||
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.
|
||||
@@ -1360,7 +1366,8 @@ report_mysql_summary () {
|
||||
# ########################################################################
|
||||
# Query cache
|
||||
# ########################################################################
|
||||
if [ "$(get_var have_query_cache "$dir/mysql-variables")" ]; then
|
||||
local has_query_cache=$(get_var have_query_cache "$dir/mysql-variables")
|
||||
if [ "$has_query_cache" = 'YES' ]; 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") ))
|
||||
@@ -1521,6 +1528,11 @@ report_mysql_summary () {
|
||||
name_val "Users" "${users}"
|
||||
name_val "Old Passwords" "$(get_var old_passwords "$dir/mysql-variables")"
|
||||
|
||||
if [ -s "$dir/mysql-roles" ]; then
|
||||
section "Roles"
|
||||
format_mysql_roles "$dir/mysql-roles"
|
||||
fi
|
||||
|
||||
# ########################################################################
|
||||
# Binary Logging
|
||||
# ########################################################################
|
||||
|
Reference in New Issue
Block a user