- section() revamp

- Redirect STDERR for the collection part in both tools
- rm_tempdir in sigtrap
- A part of pt-mysql-summary still depended on the system being run,
  rather than the samples being read. Now it works properly.
This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-04-02 19:25:17 -03:00
parent 6dbbd6de3b
commit c0dedd19bf
13 changed files with 159 additions and 95 deletions

View File

@@ -556,7 +556,12 @@ fuzzy_pct () {
section () { section () {
local str="$1" local str="$1"
local line="$(printf '#_%-60s' "${str}_" | sed -e 's/[[:space:]]/#/g' -e 's/_/ /g')" local line="$(printf '# %-60s' "${str} _" | awk '{
i = index($0, "_");
x = substr($0, i);
gsub(/[_ \t]/, "#", x);
printf("%s%s\n", substr($0, 0, i-1), x);
}')"
printf "%s\n" "${line}" printf "%s\n" "${line}"
} }
@@ -932,6 +937,11 @@ collect_mysql_info () {
cat "$cnf_file" > "$dir/mysql-config-file" cat "$cnf_file" > "$dir/mysql-config-file"
local pid_file="$(get_var "pid_file" "$dir/mysql-variables")"
local pid_file_exists=""
[ -e "${pid_file}" ] && pid_file_exists=1
echo "pt-summary-internal-pid_file_exists $pid_file_exists" >> "$dir/mysql-variables"
echo "pt-summary-internal-current_time $current_time" >> "$dir/mysql-variables" echo "pt-summary-internal-current_time $current_time" >> "$dir/mysql-variables"
echo "pt-summary-internal-Config_File_path $cnf_file" >> "$dir/mysql-variables" echo "pt-summary-internal-Config_File_path $cnf_file" >> "$dir/mysql-variables"
collect_internal_vars "$dir/mysqld-executables" >> "$dir/mysql-variables" collect_internal_vars "$dir/mysqld-executables" >> "$dir/mysql-variables"
@@ -1925,7 +1935,7 @@ section_mysqld () {
[ -e "$executables_file" -a -e "$variables_file" ] || return [ -e "$executables_file" -a -e "$variables_file" ] || return
section MySQL_Executable section "MySQL Executable"
local i=1; local i=1;
while read executable; do while read executable; do
name_val "Path to executable" "$executable" name_val "Path to executable" "$executable"
@@ -1934,15 +1944,31 @@ section_mysqld () {
done < "$executables_file" done < "$executables_file"
} }
section_mysql_files () {
local variables_file="$1"
section "MySQL Files"
for file_name in pid_file slow_query_log_file general_log_file log_error; do
local file="$(get_var "${file_name}" "$variables_file")"
local name_out="$(echo "$file_name" | sed 'y/[a-z]/[A-Z]/')"
if [ -e "${file}" ]; then
name_val "$name_out" "$file"
name_val "${name_out} Size" "$(du "$file" | awk '{print $1}')"
else
name_val "$name_out" "(does not exist)"
fi
done
}
report_mysql_summary () { report_mysql_summary () {
local dir="$1" local dir="$1"
local NAME_VAL_LEN=25 local NAME_VAL_LEN=25
section Percona_Toolkit_MySQL_Summary_Report section "Percona Toolkit MySQL Summary Report"
name_val "System time" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)" name_val "System time" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)"
section Instances section "Instances"
parse_mysqld_instances "$dir/mysqld-instances" "$dir/mysql-variables" parse_mysqld_instances "$dir/mysqld-instances" "$dir/mysql-variables"
section_mysqld "$dir/mysqld-executables" "$dir/mysql-variables" section_mysqld "$dir/mysqld-executables" "$dir/mysql-variables"
@@ -1950,7 +1976,7 @@ report_mysql_summary () {
local user="$(get_var "pt-summary-internal-user" "$dir/mysql-variables")" local user="$(get_var "pt-summary-internal-user" "$dir/mysql-variables")"
local port="$(get_var port "$dir/mysql-variables")" local port="$(get_var port "$dir/mysql-variables")"
local now="$(get_var "pt-summary-internal-now" "$dir/mysql-variables")" local now="$(get_var "pt-summary-internal-now" "$dir/mysql-variables")"
section "Report_On_Port_${port}" section "Report On Port ${port}"
name_val User "${user}" name_val User "${user}"
name_val Time "${now} ($(get_mysql_timezone "$dir/mysql-variables"))" name_val Time "${now} ($(get_mysql_timezone "$dir/mysql-variables"))"
name_val Hostname "$(get_var hostname "$dir/mysql-variables")" name_val Hostname "$(get_var hostname "$dir/mysql-variables")"
@@ -1974,37 +2000,37 @@ report_mysql_summary () {
name_val Replication "Is ${slave}a slave, has ${slavecount} slaves connected" name_val Replication "Is ${slave}a slave, has ${slavecount} slaves connected"
local pid_file="$(get_var pid_file "$dir/mysql-variables")" local pid_file="$(get_var "pid_file" "$dir/mysql-variables")"
local PID_EXISTS="" local PID_EXISTS=""
if [ -e "${pid_file}" ]; then if [ "$( get_var "pt-summary-internal-pid_file_exists" "$dir/mysql-variables" )" ]; then
PID_EXISTS="(exists)" PID_EXISTS="(exists)"
else else
PID_EXISTS="(does not exist)" PID_EXISTS="(does not exist)"
fi fi
name_val Pidfile "${pid_file} ${PID_EXISTS}" name_val Pidfile "${pid_file} ${PID_EXISTS}"
section Processlist section "Processlist"
summarize_processlist "$dir/mysql-processlist" summarize_processlist "$dir/mysql-processlist"
section "Status_Counters_(Wait_${OPT_SLEEP}_Seconds)" section "Status Counters (Wait ${OPT_SLEEP} Seconds)"
wait wait
local noncounters_pattern="$(noncounters_pattern)" local noncounters_pattern="$(noncounters_pattern)"
format_status_variables "$dir/mysql-status-defer" | grep -v "${noncounters_pattern}" format_status_variables "$dir/mysql-status-defer" | grep -v "${noncounters_pattern}"
section Table_cache section "Table cache"
local open_tables=$(get_var Open_tables "$dir/mysql-status") local open_tables=$(get_var "Open_tables" "$dir/mysql-status")
local table_cache=$(get_table_cache "$dir/mysql-variables") local table_cache=$(get_table_cache "$dir/mysql-variables")
name_val Size $table_cache name_val Size $table_cache
name_val Usage "$(fuzzy_pct ${open_tables} ${table_cache})" name_val Usage "$(fuzzy_pct ${open_tables} ${table_cache})"
section Key_Percona_Server_features section "Key Percona Server features"
section_percona_server_features "$dir/mysql-variables" section_percona_server_features "$dir/mysql-variables"
section Plugins section "Plugins"
name_val "InnoDB compression" "$(get_plugin_status "$dir/mysql-plugins" "INNODB_CMP")" name_val "InnoDB compression" "$(get_plugin_status "$dir/mysql-plugins" "INNODB_CMP")"
if [ "$(get_var have_query_cache "$dir/mysql-variables")" ]; then if [ "$(get_var have_query_cache "$dir/mysql-variables")" ]; then
section Query_cache section "Query cache"
local query_cache_size=$(get_var query_cache_size "$dir/mysql-variables") 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") )) local used=$(( ${query_cache_size} - $(get_var Qcache_free_memory "$dir/mysql-status") ))
local hrat=$(fuzzy_pct $(get_var Qcache_hits "$dir/mysql-status") $(get_var Qcache_inserts "$dir/mysql-status")) local hrat=$(fuzzy_pct $(get_var Qcache_hits "$dir/mysql-status") $(get_var Qcache_inserts "$dir/mysql-status"))
@@ -2014,9 +2040,9 @@ report_mysql_summary () {
name_val HitToInsertRatio "${hrat}" name_val HitToInsertRatio "${hrat}"
fi fi
local semisync_enabled_master="$(get_var rpl_semi_sync_master_enabled "$dir/mysql-variables")" local semisync_enabled_master="$(get_var "rpl_semi_sync_master_enabled" "$dir/mysql-variables")"
if [ -n "${semisync_enabled_master}" ]; then if [ -n "${semisync_enabled_master}" ]; then
section Semisynchronous_Replication section "Semisynchronous Replication"
if [ "$semisync_enabled_master" = "OFF" -o "$semisync_enabled_master" = "0" -o -z "$semisync_enabled_master" ]; then if [ "$semisync_enabled_master" = "OFF" -o "$semisync_enabled_master" = "0" -o -z "$semisync_enabled_master" ]; then
name_val "Master" "Disabled" name_val "Master" "Disabled"
else else
@@ -2030,7 +2056,7 @@ report_mysql_summary () {
fi fi
fi fi
section Schema section "Schema"
local reply="n" local reply="n"
if [ "${OPT_DATABASES}" ] || [ "${OPT_READ_SAMPLES}" ] \ if [ "${OPT_DATABASES}" ] || [ "${OPT_READ_SAMPLES}" ] \
|| [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ]; then || [ -e "$dir/mysqldump" -a -s "$dir/mysqldump" ]; then
@@ -2064,7 +2090,7 @@ report_mysql_summary () {
echo "Skipping schema analysis" echo "Skipping schema analysis"
fi fi
section "Noteworthy_Technologies" section "Noteworthy Technologies"
if [ -s "$dir/mysqldump" ]; then if [ -s "$dir/mysqldump" ]; then
if grep FULLTEXT "$dir/mysqldump" > /dev/null; then if grep FULLTEXT "$dir/mysqldump" > /dev/null; then
name_val "Full Text Indexing" "Yes" name_val "Full Text Indexing" "Yes"
@@ -2134,8 +2160,8 @@ report_mysql_summary () {
name_val "Prepared statement count" "${prep_count}" name_val "Prepared statement count" "${prep_count}"
fi fi
section InnoDB section "InnoDB"
local have_innodb="$(get_var have_innodb "$dir/mysql-variables")" local have_innodb="$(get_var "have_innodb" "$dir/mysql-variables")"
if [ "${have_innodb}" = "YES" ]; then if [ "${have_innodb}" = "YES" ]; then
section_innodb "$dir/mysql-variables" "$dir/mysql-status" section_innodb "$dir/mysql-variables" "$dir/mysql-status"
@@ -2144,15 +2170,15 @@ report_mysql_summary () {
fi fi
fi fi
section MyISAM section "MyISAM"
section_myisam "$dir/mysql-variables" "$dir/mysql-status" section_myisam "$dir/mysql-variables" "$dir/mysql-status"
section Security section "Security"
local users="$( format_users "$dir/mysql-users" )" local users="$( format_users "$dir/mysql-users" )"
name_val Users "${users}" name_val "Users" "${users}"
name_val "Old Passwords" "$(get_var old_passwords "$dir/mysql-variables")" name_val "Old Passwords" "$(get_var old_passwords "$dir/mysql-variables")"
section Binary_Logging section "Binary Logging"
if [ -s "$dir/mysql-master-logs" ] \ if [ -s "$dir/mysql-master-logs" ] \
|| [ -s "$dir/mysql-master-status" ]; then || [ -s "$dir/mysql-master-status" ]; then
@@ -2166,10 +2192,10 @@ report_mysql_summary () {
fi fi
section Noteworthy_Variables section "Noteworthy Variables"
section_noteworthy_variables "$dir/mysql-variables" section_noteworthy_variables "$dir/mysql-variables"
section Configuration_File section "Configuration File"
local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")" local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")"
if [ -n "${cnf_file}" ]; then if [ -n "${cnf_file}" ]; then
name_val "Config File" "${cnf_file}" name_val "Config File" "${cnf_file}"
@@ -2178,7 +2204,7 @@ report_mysql_summary () {
name_val "Config File" "Cannot autodetect or find, giving up" name_val "Config File" "Cannot autodetect or find, giving up"
fi fi
section The_End section "The End"
} }
# ########################################################################### # ###########################################################################
@@ -2213,6 +2239,7 @@ check_mysql () {
sigtrap() { sigtrap() {
warn "Caught signal, forcing exit" warn "Caught signal, forcing exit"
rm_tmpdir
exit $EXIT_STATUS exit $EXIT_STATUS
} }
@@ -2254,7 +2281,7 @@ main() {
# ##################################################################### # #####################################################################
# Fetch most info, leave a child in the background gathering the rest # Fetch most info, leave a child in the background gathering the rest
# ##################################################################### # #####################################################################
collect_mysql_info "${data_dir}" collect_mysql_info "${data_dir}" 2>"${data_dir}/collect.err"
fi fi
# ######################################################################## # ########################################################################

View File

@@ -693,7 +693,12 @@ fuzzy_pct () {
section () { section () {
local str="$1" local str="$1"
local line="$(printf '#_%-60s' "${str}_" | sed -e 's/[[:space:]]/#/g' -e 's/_/ /g')" local line="$(printf '# %-60s' "${str} _" | awk '{
i = index($0, "_");
x = substr($0, i);
gsub(/[_ \t]/, "#", x);
printf("%s%s\n", substr($0, 0, i-1), x);
}')"
printf "%s\n" "${line}" printf "%s\n" "${line}"
} }
@@ -1897,12 +1902,12 @@ processes_section () { local PTFUNCNAME=processes_section;
local vmstat_file="$3" local vmstat_file="$3"
local platform="$4" local platform="$4"
section "Top_Processes" section "Top Processes"
cat "$top_process_file" cat "$top_process_file"
section "Notable_Processes" section "Notable Processes"
cat "$notable_procs_file" cat "$notable_procs_file"
if [ -e "$vmstat_file" ]; then if [ -e "$vmstat_file" ]; then
section "Simplified_and_fuzzy_rounded_vmstat_(wait_please)" section "Simplified and fuzzy rounded vmstat (wait please)"
wait # For the process we forked that was gathering vmstat samples wait # For the process we forked that was gathering vmstat samples
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
format_vmstat "$vmstat_file" format_vmstat "$vmstat_file"
@@ -1980,7 +1985,7 @@ parse_uptime () {
report_system_summary () { local PTFUNCNAME=report_system_summary; report_system_summary () { local PTFUNCNAME=report_system_summary;
local data_dir="$1" local data_dir="$1"
section "Percona_Toolkit_System_Summary_Report" section "Percona Toolkit System Summary Report"
[ -e "$data_dir/summary" ] \ [ -e "$data_dir/summary" ] \
@@ -2021,34 +2026,34 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ -s "$data_dir/mounted_fs" ]; then if [ -s "$data_dir/mounted_fs" ]; then
section "Mounted_Filesystems" section "Mounted Filesystems"
parse_filesystems "$data_dir/mounted_fs" "${platform}" parse_filesystems "$data_dir/mounted_fs" "${platform}"
fi fi
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
section "Disk_Schedulers_And_Queue_Size" section "Disk Schedulers And Queue Size"
local disks="$( get_var "internal::disks" "$data_dir/summary" )" local disks="$( get_var "internal::disks" "$data_dir/summary" )"
for disk in $disks; do for disk in $disks; do
local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )" local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )"
name_val "${disk}" "${scheduler:-"UNREADABLE"}" name_val "${disk}" "${scheduler:-"UNREADABLE"}"
done done
section "Disk_Partioning" section "Disk Partioning"
parse_fdisk "$data_dir/partitioning" parse_fdisk "$data_dir/partitioning"
section "Kernel_Inode_State" section "Kernel Inode State"
for file in dentry-state file-nr inode-nr; do for file in dentry-state file-nr inode-nr; do
name_val "${file}" "$(get_var "${file}" "$data_dir/summary")" name_val "${file}" "$(get_var "${file}" "$data_dir/summary")"
done done
section "LVM_Volumes" section "LVM Volumes"
format_lvs "$data_dir/lvs" format_lvs "$data_dir/lvs"
section "LVM_Volume_Groups" section "LVM Volume Groups"
format_lvs "$data_dir/vgs" format_lvs "$data_dir/vgs"
fi fi
section "RAID_Controller" section "RAID Controller"
local controller="$(get_var "raid_controller" "$data_dir/summary")" local controller="$(get_var "raid_controller" "$data_dir/summary")"
name_val "Controller" "$controller" name_val "Controller" "$controller"
local key="$(get_var "internal::raid_opt" "$data_dir/summary")" local key="$(get_var "internal::raid_opt" "$data_dir/summary")"
@@ -2076,7 +2081,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ "${OPT_SUMMARIZE_NETWORK}" ]; then if [ "${OPT_SUMMARIZE_NETWORK}" ]; then
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
section "Network_Config" section "Network Config"
if [ -s "$data_dir/lspci_file" ]; then if [ -s "$data_dir/lspci_file" ]; then
parse_ethernet_controller_lspci "$data_dir/lspci_file" parse_ethernet_controller_lspci "$data_dir/lspci_file"
fi fi
@@ -2088,17 +2093,17 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ -s "$data_dir/ip" ]; then if [ -s "$data_dir/ip" ]; then
section "Interface_Statistics" section "Interface Statistics"
parse_ip_s_link "$data_dir/ip" parse_ip_s_link "$data_dir/ip"
fi fi
if [ -s "$data_dir/network_devices" ]; then if [ -s "$data_dir/network_devices" ]; then
section "Network_Devices" section "Network Devices"
parse_ethtool "$data_dir/network_devices" parse_ethtool "$data_dir/network_devices"
fi fi
if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then
section "Network_Connections" section "Network Connections"
parse_netstat "$data_dir/netstat" parse_netstat "$data_dir/netstat"
fi fi
fi fi
@@ -2109,7 +2114,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
"$data_dir/vmstat" \ "$data_dir/vmstat" \
"$platform" "$platform"
section "The_End" section "The End"
} }
# ########################################################################### # ###########################################################################
@@ -2144,7 +2149,7 @@ main () { local PTFUNCNAME=main;
if [ -n "$OPT_READ_SAMPLES" -a -d "$OPT_READ_SAMPLES" ]; then if [ -n "$OPT_READ_SAMPLES" -a -d "$OPT_READ_SAMPLES" ]; then
data_dir="$OPT_READ_SAMPLES" data_dir="$OPT_READ_SAMPLES"
else else
collect_system_data "$data_dir" collect_system_data "$data_dir" 2>"$data_dir/collect.err"
fi fi
report_system_summary "$data_dir" report_system_summary "$data_dir"
@@ -2154,6 +2159,7 @@ main () { local PTFUNCNAME=main;
sigtrap() { local PTFUNCNAME=sigtrap; sigtrap() { local PTFUNCNAME=sigtrap;
warn "Caught signal, forcing exit" warn "Caught signal, forcing exit"
rm_tmpdir
exit $EXIT_STATUS exit $EXIT_STATUS
} }

View File

@@ -234,6 +234,11 @@ collect_mysql_info () {
cat "$cnf_file" > "$dir/mysql-config-file" cat "$cnf_file" > "$dir/mysql-config-file"
local pid_file="$(get_var "pid_file" "$dir/mysql-variables")"
local pid_file_exists=""
[ -e "${pid_file}" ] && pid_file_exists=1
echo "pt-summary-internal-pid_file_exists $pid_file_exists" >> "$dir/mysql-variables"
# TODO: Do these require a file of their own? # TODO: Do these require a file of their own?
echo "pt-summary-internal-current_time $current_time" >> "$dir/mysql-variables" echo "pt-summary-internal-current_time $current_time" >> "$dir/mysql-variables"
echo "pt-summary-internal-Config_File_path $cnf_file" >> "$dir/mysql-variables" echo "pt-summary-internal-Config_File_path $cnf_file" >> "$dir/mysql-variables"

View File

@@ -64,7 +64,12 @@ fuzzy_pct () {
# with #'s and all underscores with spaces. # with #'s and all underscores with spaces.
section () { section () {
local str="$1" local str="$1"
local line="$(printf '#_%-60s' "${str}_" | sed -e 's/[[:space:]]/#/g' -e 's/_/ /g')" local line="$(printf '# %-60s' "${str} _" | awk '{
i = index($0, "_");
x = substr($0, i);
gsub(/[_ \t]/, "#", x);
printf("%s%s\n", substr($0, 0, i-1), x);
}')"
printf "%s\n" "${line}" printf "%s\n" "${line}"
} }

View File

@@ -1049,7 +1049,7 @@ section_mysqld () {
[ -e "$executables_file" -a -e "$variables_file" ] || return [ -e "$executables_file" -a -e "$variables_file" ] || return
section MySQL_Executable section "MySQL Executable"
local i=1; local i=1;
while read executable; do while read executable; do
name_val "Path to executable" "$executable" name_val "Path to executable" "$executable"
@@ -1058,6 +1058,22 @@ section_mysqld () {
done < "$executables_file" done < "$executables_file"
} }
section_mysql_files () {
local variables_file="$1"
section "MySQL Files"
for file_name in pid_file slow_query_log_file general_log_file log_error; do
local file="$(get_var "${file_name}" "$variables_file")"
local name_out="$(echo "$file_name" | sed 'y/[a-z]/[A-Z]/')"
if [ -e "${file}" ]; then
name_val "$name_out" "$file"
name_val "${name_out} Size" "$(du "$file" | awk '{print $1}')"
else
name_val "$name_out" "(does not exist)"
fi
done
}
report_mysql_summary () { report_mysql_summary () {
local dir="$1" local dir="$1"
@@ -1068,9 +1084,9 @@ report_mysql_summary () {
# Header for the whole thing, table of discovered instances # Header for the whole thing, table of discovered instances
# ######################################################################## # ########################################################################
section Percona_Toolkit_MySQL_Summary_Report section "Percona Toolkit MySQL Summary Report"
name_val "System time" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)" name_val "System time" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)"
section Instances section "Instances"
parse_mysqld_instances "$dir/mysqld-instances" "$dir/mysql-variables" parse_mysqld_instances "$dir/mysqld-instances" "$dir/mysql-variables"
section_mysqld "$dir/mysqld-executables" "$dir/mysql-variables" section_mysqld "$dir/mysqld-executables" "$dir/mysql-variables"
@@ -1081,7 +1097,7 @@ report_mysql_summary () {
local user="$(get_var "pt-summary-internal-user" "$dir/mysql-variables")" local user="$(get_var "pt-summary-internal-user" "$dir/mysql-variables")"
local port="$(get_var port "$dir/mysql-variables")" local port="$(get_var port "$dir/mysql-variables")"
local now="$(get_var "pt-summary-internal-now" "$dir/mysql-variables")" local now="$(get_var "pt-summary-internal-now" "$dir/mysql-variables")"
section "Report_On_Port_${port}" section "Report On Port ${port}"
name_val User "${user}" name_val User "${user}"
name_val Time "${now} ($(get_mysql_timezone "$dir/mysql-variables"))" name_val Time "${now} ($(get_mysql_timezone "$dir/mysql-variables"))"
name_val Hostname "$(get_var hostname "$dir/mysql-variables")" name_val Hostname "$(get_var hostname "$dir/mysql-variables")"
@@ -1107,9 +1123,10 @@ report_mysql_summary () {
# TODO move this into a section with other files: error log, slow log and # TODO move this into a section with other files: error log, slow log and
# show the sizes # show the sizes
local pid_file="$(get_var pid_file "$dir/mysql-variables")" # section_mysql_files "$dir/mysql-variables"
local pid_file="$(get_var "pid_file" "$dir/mysql-variables")"
local PID_EXISTS="" local PID_EXISTS=""
if [ -e "${pid_file}" ]; then if [ "$( get_var "pt-summary-internal-pid_file_exists" "$dir/mysql-variables" )" ]; then
PID_EXISTS="(exists)" PID_EXISTS="(exists)"
else else
PID_EXISTS="(does not exist)" PID_EXISTS="(does not exist)"
@@ -1119,13 +1136,13 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# Processlist, sliced several different ways # Processlist, sliced several different ways
# ######################################################################## # ########################################################################
section Processlist section "Processlist"
summarize_processlist "$dir/mysql-processlist" summarize_processlist "$dir/mysql-processlist"
# ######################################################################## # ########################################################################
# Queries and query plans # Queries and query plans
# ######################################################################## # ########################################################################
section "Status_Counters_(Wait_${OPT_SLEEP}_Seconds)" section "Status Counters (Wait ${OPT_SLEEP} Seconds)"
# Wait for the child that was forked during collection. # Wait for the child that was forked during collection.
wait wait
local noncounters_pattern="$(noncounters_pattern)" local noncounters_pattern="$(noncounters_pattern)"
@@ -1134,8 +1151,8 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# Table cache # Table cache
# ######################################################################## # ########################################################################
section Table_cache section "Table cache"
local open_tables=$(get_var Open_tables "$dir/mysql-status") local open_tables=$(get_var "Open_tables" "$dir/mysql-status")
local table_cache=$(get_table_cache "$dir/mysql-variables") local table_cache=$(get_table_cache "$dir/mysql-variables")
name_val Size $table_cache name_val Size $table_cache
name_val Usage "$(fuzzy_pct ${open_tables} ${table_cache})" name_val Usage "$(fuzzy_pct ${open_tables} ${table_cache})"
@@ -1143,21 +1160,21 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# Percona Server features # Percona Server features
# ######################################################################## # ########################################################################
section Key_Percona_Server_features section "Key Percona Server features"
section_percona_server_features "$dir/mysql-variables" section_percona_server_features "$dir/mysql-variables"
# ######################################################################## # ########################################################################
# Plugins # Plugins
# ######################################################################## # ########################################################################
# TODO: what would be good is to show nonstandard plugins here. # TODO: what would be good is to show nonstandard plugins here.
section Plugins section "Plugins"
name_val "InnoDB compression" "$(get_plugin_status "$dir/mysql-plugins" "INNODB_CMP")" name_val "InnoDB compression" "$(get_plugin_status "$dir/mysql-plugins" "INNODB_CMP")"
# ######################################################################## # ########################################################################
# Query cache # Query cache
# ######################################################################## # ########################################################################
if [ "$(get_var have_query_cache "$dir/mysql-variables")" ]; then if [ "$(get_var have_query_cache "$dir/mysql-variables")" ]; then
section Query_cache section "Query cache"
local query_cache_size=$(get_var query_cache_size "$dir/mysql-variables") 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") )) local used=$(( ${query_cache_size} - $(get_var Qcache_free_memory "$dir/mysql-status") ))
local hrat=$(fuzzy_pct $(get_var Qcache_hits "$dir/mysql-status") $(get_var Qcache_inserts "$dir/mysql-status")) local hrat=$(fuzzy_pct $(get_var Qcache_hits "$dir/mysql-status") $(get_var Qcache_inserts "$dir/mysql-status"))
@@ -1167,9 +1184,9 @@ report_mysql_summary () {
name_val HitToInsertRatio "${hrat}" name_val HitToInsertRatio "${hrat}"
fi fi
local semisync_enabled_master="$(get_var rpl_semi_sync_master_enabled "$dir/mysql-variables")" local semisync_enabled_master="$(get_var "rpl_semi_sync_master_enabled" "$dir/mysql-variables")"
if [ -n "${semisync_enabled_master}" ]; then if [ -n "${semisync_enabled_master}" ]; then
section Semisynchronous_Replication section "Semisynchronous Replication"
if [ "$semisync_enabled_master" = "OFF" -o "$semisync_enabled_master" = "0" -o -z "$semisync_enabled_master" ]; then if [ "$semisync_enabled_master" = "OFF" -o "$semisync_enabled_master" = "0" -o -z "$semisync_enabled_master" ]; then
name_val "Master" "Disabled" name_val "Master" "Disabled"
else else
@@ -1186,7 +1203,7 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# Schema, databases, data type, other analysis. # Schema, databases, data type, other analysis.
# ######################################################################## # ########################################################################
section Schema section "Schema"
# Assume "no" if stdin or stdout is not a terminal, so this can be run and # Assume "no" if stdin or stdout is not a terminal, so this can be run and
# put into a file, or piped into a pager, or something else like that. # put into a file, or piped into a pager, or something else like that.
local reply="n" local reply="n"
@@ -1231,7 +1248,7 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# Noteworthy Technologies # Noteworthy Technologies
# ######################################################################## # ########################################################################
section "Noteworthy_Technologies" section "Noteworthy Technologies"
if [ -s "$dir/mysqldump" ]; then if [ -s "$dir/mysqldump" ]; then
if grep FULLTEXT "$dir/mysqldump" > /dev/null; then if grep FULLTEXT "$dir/mysqldump" > /dev/null; then
name_val "Full Text Indexing" "Yes" name_val "Full Text Indexing" "Yes"
@@ -1304,8 +1321,8 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# InnoDB # InnoDB
# ######################################################################## # ########################################################################
section InnoDB section "InnoDB"
local have_innodb="$(get_var have_innodb "$dir/mysql-variables")" local have_innodb="$(get_var "have_innodb" "$dir/mysql-variables")"
if [ "${have_innodb}" = "YES" ]; then if [ "${have_innodb}" = "YES" ]; then
section_innodb "$dir/mysql-variables" "$dir/mysql-status" section_innodb "$dir/mysql-variables" "$dir/mysql-status"
@@ -1317,22 +1334,21 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# MyISAM # MyISAM
# ######################################################################## # ########################################################################
section MyISAM section "MyISAM"
section_myisam "$dir/mysql-variables" "$dir/mysql-status" section_myisam "$dir/mysql-variables" "$dir/mysql-status"
# ######################################################################## # ########################################################################
# Users & Security # Users & Security
# ######################################################################## # ########################################################################
section Security section "Security"
local users="$( format_users "$dir/mysql-users" )" local users="$( format_users "$dir/mysql-users" )"
# XXX TODO Give it a different formatting? name_val "Users" "${users}"
name_val Users "${users}"
name_val "Old Passwords" "$(get_var old_passwords "$dir/mysql-variables")" name_val "Old Passwords" "$(get_var old_passwords "$dir/mysql-variables")"
# ######################################################################## # ########################################################################
# Binary Logging # Binary Logging
# ######################################################################## # ########################################################################
section Binary_Logging section "Binary Logging"
if [ -s "$dir/mysql-master-logs" ] \ if [ -s "$dir/mysql-master-logs" ] \
|| [ -s "$dir/mysql-master-status" ]; then || [ -s "$dir/mysql-master-status" ]; then
@@ -1351,13 +1367,13 @@ report_mysql_summary () {
# ######################################################################## # ########################################################################
# Interesting things that you just ought to know about. # Interesting things that you just ought to know about.
# ######################################################################## # ########################################################################
section Noteworthy_Variables section "Noteworthy Variables"
section_noteworthy_variables "$dir/mysql-variables" section_noteworthy_variables "$dir/mysql-variables"
# ######################################################################## # ########################################################################
# If there is a my.cnf in a standard location, see if we can pretty-print it. # If there is a my.cnf in a standard location, see if we can pretty-print it.
# ######################################################################## # ########################################################################
section Configuration_File section "Configuration File"
local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")" local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")"
if [ -n "${cnf_file}" ]; then if [ -n "${cnf_file}" ]; then
name_val "Config File" "${cnf_file}" name_val "Config File" "${cnf_file}"
@@ -1367,7 +1383,7 @@ report_mysql_summary () {
fi fi
# Make sure that we signal the end of the tool's output. # Make sure that we signal the end of the tool's output.
section The_End section "The End"
} }
# ########################################################################### # ###########################################################################

View File

@@ -802,12 +802,12 @@ processes_section () { local PTFUNCNAME=processes_section;
local vmstat_file="$3" local vmstat_file="$3"
local platform="$4" local platform="$4"
section "Top_Processes" section "Top Processes"
cat "$top_process_file" cat "$top_process_file"
section "Notable_Processes" section "Notable Processes"
cat "$notable_procs_file" cat "$notable_procs_file"
if [ -e "$vmstat_file" ]; then if [ -e "$vmstat_file" ]; then
section "Simplified_and_fuzzy_rounded_vmstat_(wait_please)" section "Simplified and fuzzy rounded vmstat (wait please)"
wait # For the process we forked that was gathering vmstat samples wait # For the process we forked that was gathering vmstat samples
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
format_vmstat "$vmstat_file" format_vmstat "$vmstat_file"
@@ -888,7 +888,7 @@ parse_uptime () {
report_system_summary () { local PTFUNCNAME=report_system_summary; report_system_summary () { local PTFUNCNAME=report_system_summary;
local data_dir="$1" local data_dir="$1"
section "Percona_Toolkit_System_Summary_Report" section "Percona Toolkit System Summary Report"
# ######################################################################## # ########################################################################
# General date, time, load, etc # General date, time, load, etc
@@ -939,34 +939,34 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
# TODO: Add info about software RAID # TODO: Add info about software RAID
if [ -s "$data_dir/mounted_fs" ]; then if [ -s "$data_dir/mounted_fs" ]; then
section "Mounted_Filesystems" section "Mounted Filesystems"
parse_filesystems "$data_dir/mounted_fs" "${platform}" parse_filesystems "$data_dir/mounted_fs" "${platform}"
fi fi
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
section "Disk_Schedulers_And_Queue_Size" section "Disk Schedulers And Queue Size"
local disks="$( get_var "internal::disks" "$data_dir/summary" )" local disks="$( get_var "internal::disks" "$data_dir/summary" )"
for disk in $disks; do for disk in $disks; do
local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )" local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )"
name_val "${disk}" "${scheduler:-"UNREADABLE"}" name_val "${disk}" "${scheduler:-"UNREADABLE"}"
done done
section "Disk_Partioning" section "Disk Partioning"
parse_fdisk "$data_dir/partitioning" parse_fdisk "$data_dir/partitioning"
section "Kernel_Inode_State" section "Kernel Inode State"
for file in dentry-state file-nr inode-nr; do for file in dentry-state file-nr inode-nr; do
name_val "${file}" "$(get_var "${file}" "$data_dir/summary")" name_val "${file}" "$(get_var "${file}" "$data_dir/summary")"
done done
section "LVM_Volumes" section "LVM Volumes"
format_lvs "$data_dir/lvs" format_lvs "$data_dir/lvs"
section "LVM_Volume_Groups" section "LVM Volume Groups"
format_lvs "$data_dir/vgs" format_lvs "$data_dir/vgs"
fi fi
section "RAID_Controller" section "RAID Controller"
local controller="$(get_var "raid_controller" "$data_dir/summary")" local controller="$(get_var "raid_controller" "$data_dir/summary")"
name_val "Controller" "$controller" name_val "Controller" "$controller"
local key="$(get_var "internal::raid_opt" "$data_dir/summary")" local key="$(get_var "internal::raid_opt" "$data_dir/summary")"
@@ -1000,7 +1000,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
# Network stuff # Network stuff
# ##################################################################### # #####################################################################
if [ "${platform}" = "Linux" ]; then if [ "${platform}" = "Linux" ]; then
section "Network_Config" section "Network Config"
if [ -s "$data_dir/lspci_file" ]; then if [ -s "$data_dir/lspci_file" ]; then
parse_ethernet_controller_lspci "$data_dir/lspci_file" parse_ethernet_controller_lspci "$data_dir/lspci_file"
fi fi
@@ -1015,17 +1015,17 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
# in new kernels like Fedora 12? # in new kernels like Fedora 12?
if [ -s "$data_dir/ip" ]; then if [ -s "$data_dir/ip" ]; then
section "Interface_Statistics" section "Interface Statistics"
parse_ip_s_link "$data_dir/ip" parse_ip_s_link "$data_dir/ip"
fi fi
if [ -s "$data_dir/network_devices" ]; then if [ -s "$data_dir/network_devices" ]; then
section "Network_Devices" section "Network Devices"
parse_ethtool "$data_dir/network_devices" parse_ethtool "$data_dir/network_devices"
fi fi
if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then
section "Network_Connections" section "Network Connections"
parse_netstat "$data_dir/netstat" parse_netstat "$data_dir/netstat"
fi fi
fi fi
@@ -1042,7 +1042,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
# ######################################################################## # ########################################################################
# All done. Signal the end so it's explicit. # All done. Signal the end so it's explicit.
# ######################################################################## # ########################################################################
section "The_End" section "The End"
} }
# ########################################################################### # ###########################################################################

View File

@@ -68,13 +68,13 @@ is \
is \ is \
"$(section "A B C")" \ "$(section "A B C")" \
"# A#B#C ######################################################" \ "# A B C ######################################################" \
"section replaces all spaces with #s" "section doesn't replaces spaces with #s"
is \ is \
"$(section "A_B_C")" \ "$(section "A_B_C")" \
"# A B C ######################################################" \ "# A#B#C#######################################################" \
"..and all underscores with spaces" "..but it does replace everything after and including the first underscore with #s"
# name_val # name_val

View File

@@ -36,7 +36,7 @@ my @files = glob("$dir/*");
is( is(
scalar @files, scalar @files,
14, 15,
"And leaves all files in there" "And leaves all files in there"
); );

View File

@@ -353,3 +353,4 @@ pt-summary-internal-user hugmeir@localhost
pt-summary-internal-FNV_64 Unknown pt-summary-internal-FNV_64 Unknown
pt-summary-internal-trigger_count 0 pt-summary-internal-trigger_count 0
pt-summary-internal-symbols Yes pt-summary-internal-symbols Yes
pt-summary-internal-pid_file_exists 1

View File

@@ -369,3 +369,4 @@ pt-summary-internal-user hugmeir@localhost
pt-summary-internal-FNV_64 Unknown pt-summary-internal-FNV_64 Unknown
pt-summary-internal-trigger_count 0 pt-summary-internal-trigger_count 0
pt-summary-internal-symbols Yes pt-summary-internal-symbols Yes
pt-summary-internal-pid_file_exists

View File

@@ -282,3 +282,4 @@ pt-summary-internal-user msandbox@%
pt-summary-internal-FNV_64 Unknown pt-summary-internal-FNV_64 Unknown
pt-summary-internal-trigger_count 0 pt-summary-internal-trigger_count 0
pt-summary-internal-symbols Yes pt-summary-internal-symbols Yes
pt-summary-internal-pid_file_exists 1

View File

@@ -282,3 +282,4 @@ pt-summary-internal-user msandbox@%
pt-summary-internal-FNV_64 Unknown pt-summary-internal-FNV_64 Unknown
pt-summary-internal-trigger_count 6 pt-summary-internal-trigger_count 6
pt-summary-internal-symbols No pt-summary-internal-symbols No
pt-summary-internal-pid_file_exists 1

View File

@@ -360,3 +360,4 @@ pt-summary-internal-user msandbox@%
pt-summary-internal-FNV_64 Unknown pt-summary-internal-FNV_64 Unknown
pt-summary-internal-trigger_count 6 pt-summary-internal-trigger_count 6
pt-summary-internal-mysqld_executable_1 Yes pt-summary-internal-mysqld_executable_1 Yes
pt-summary-internal-pid_file_exists 1