- 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

@@ -693,7 +693,12 @@ fuzzy_pct () {
section () {
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}"
}
@@ -1897,12 +1902,12 @@ processes_section () { local PTFUNCNAME=processes_section;
local vmstat_file="$3"
local platform="$4"
section "Top_Processes"
section "Top Processes"
cat "$top_process_file"
section "Notable_Processes"
section "Notable Processes"
cat "$notable_procs_file"
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
if [ "${platform}" = "Linux" ]; then
format_vmstat "$vmstat_file"
@@ -1980,7 +1985,7 @@ parse_uptime () {
report_system_summary () { local PTFUNCNAME=report_system_summary;
local data_dir="$1"
section "Percona_Toolkit_System_Summary_Report"
section "Percona Toolkit System Summary Report"
[ -e "$data_dir/summary" ] \
@@ -2021,34 +2026,34 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ -s "$data_dir/mounted_fs" ]; then
section "Mounted_Filesystems"
section "Mounted Filesystems"
parse_filesystems "$data_dir/mounted_fs" "${platform}"
fi
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" )"
for disk in $disks; do
local scheduler="$( get_var "internal::${disk}" "$data_dir/summary" )"
name_val "${disk}" "${scheduler:-"UNREADABLE"}"
done
section "Disk_Partioning"
section "Disk Partioning"
parse_fdisk "$data_dir/partitioning"
section "Kernel_Inode_State"
section "Kernel Inode State"
for file in dentry-state file-nr inode-nr; do
name_val "${file}" "$(get_var "${file}" "$data_dir/summary")"
done
section "LVM_Volumes"
section "LVM Volumes"
format_lvs "$data_dir/lvs"
section "LVM_Volume_Groups"
section "LVM Volume Groups"
format_lvs "$data_dir/vgs"
fi
section "RAID_Controller"
section "RAID Controller"
local controller="$(get_var "raid_controller" "$data_dir/summary")"
name_val "Controller" "$controller"
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 [ "${platform}" = "Linux" ]; then
section "Network_Config"
section "Network Config"
if [ -s "$data_dir/lspci_file" ]; then
parse_ethernet_controller_lspci "$data_dir/lspci_file"
fi
@@ -2088,17 +2093,17 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
if [ -s "$data_dir/ip" ]; then
section "Interface_Statistics"
section "Interface Statistics"
parse_ip_s_link "$data_dir/ip"
fi
if [ -s "$data_dir/network_devices" ]; then
section "Network_Devices"
section "Network Devices"
parse_ethtool "$data_dir/network_devices"
fi
if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then
section "Network_Connections"
section "Network Connections"
parse_netstat "$data_dir/netstat"
fi
fi
@@ -2109,7 +2114,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
"$data_dir/vmstat" \
"$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
data_dir="$OPT_READ_SAMPLES"
else
collect_system_data "$data_dir"
collect_system_data "$data_dir" 2>"$data_dir/collect.err"
fi
report_system_summary "$data_dir"
@@ -2154,6 +2159,7 @@ main () { local PTFUNCNAME=main;
sigtrap() { local PTFUNCNAME=sigtrap;
warn "Caught signal, forcing exit"
rm_tmpdir
exit $EXIT_STATUS
}