mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
PT-2102_pt-mysql-summary should support include in config files (#601)
* PT-2102 pt-mysql-summary should support include* in config file includedir directories are now printed in the order of which they appear in root my.cnf * PT-2102 pt-mysql-summary should support include* in config file !include was not supported. Changed 'for' to 'while' to properly test for '!includedir' and '!include'. Supports extra spaces between files and !include. * PT-2102 pt-mysql-summary should support include* in config file Updates modules, added test case for !include and !includedir Changed find_my_cnf function to make it try every regexes and only returned when it find one * Update pt-mysql-summary Identation fix as suggested by review * Update collect_mysql_info.sh Identation as suggested by review * PT-2102 pt-mysql-summary should support include* in config file Fix formatting after review --------- Co-authored-by: Sveta Smirnova <svetasmirnova@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
bc370d2c1d
commit
7ecdae6ef6
@@ -878,11 +878,17 @@ find_my_cnf_file() {
|
||||
if [ "$port" ]; then
|
||||
cnf_file="$(grep --max-count 1 "/mysqld.*--port=$port" "$file" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }')"
|
||||
else
|
||||
cnf_file="$(grep --max-count 1 '/mysqld' "$file" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }')"
|
||||
|
||||
if [ -n "$cnf_file" ]; then
|
||||
echo "$cnf_file"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
cnf_file="$(grep --max-count 1 '/mysqld' "$file" \
|
||||
| awk 'BEGIN{RS=" "; FS="=";} $1 ~ /--defaults-file/ { print $2; }')"
|
||||
|
||||
|
||||
if [ -z "$cnf_file" ]; then
|
||||
if [ -e "/etc/my.cnf" ]; then
|
||||
cnf_file="/etc/my.cnf"
|
||||
@@ -1419,6 +1425,25 @@ pretty_print_cnf_file () {
|
||||
}
|
||||
}' "$file"
|
||||
|
||||
while read line; do
|
||||
echo $line | grep -q '!include'
|
||||
if [ $? -eq 0 ]; then
|
||||
clause=$(echo -n $line | tr -s ' ' | cut -d ' ' -f 1)
|
||||
include=$(echo -n $line | tr -s ' ' | cut -d ' ' -f 2)
|
||||
|
||||
if [ "x$include" != "x" -a -d "${include}" -a "x$clause" = 'x!includedir' ]; then
|
||||
for subfile in $(find -L "$include" -type f -maxdepth 1 -name *.cnf ); do
|
||||
echo "# $subfile"
|
||||
pretty_print_cnf_file $subfile
|
||||
done
|
||||
elif [ -f "$include" -a "$clause" = '!include' ]; then
|
||||
echo "# $include"
|
||||
pretty_print_cnf_file $include
|
||||
fi
|
||||
fi
|
||||
|
||||
done < "$file"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user