mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-02-28 02:07:54 +08:00
PT-1052 include numa information in pt tool output (#547)
* PT-1052: fix for pt-summary
* Re-added fix from commit 71fae6d117 into proper place: library directory
Added tests for PT-1052 (pt-summary only)
* Fixed tests for pt-summary,
set locale for pt-summary tests, so they are not affected by user environment.
Finished tests for PT-1052
* Added fix for PT-1983 into the proper place: library file
* PT-1052: fix for pt-stalk which now includes numastat data
This commit is contained in:
@@ -1036,6 +1036,10 @@ collect_system_data_loop() {
|
||||
(echo $ts; df -k) >> "$d/$p-df" &
|
||||
(echo $ts; netstat -antp) >> "$d/$p-netstat" &
|
||||
(echo $ts; netstat -s) >> "$d/$p-netstat_s" &
|
||||
(echo $ts;
|
||||
for node in `ls -d /sys/devices/system/node/node*`; do
|
||||
echo `basename $node`; cat "$node/numastat"
|
||||
done) >> "$d/$p-numastat" &
|
||||
}
|
||||
|
||||
collect_mysql_data_two() {
|
||||
|
||||
118
bin/pt-summary
118
bin/pt-summary
@@ -16,10 +16,10 @@ export POSIXLY_CORRECT
|
||||
# ###########################################################################
|
||||
# log_warn_die package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/log_warn_die.sh
|
||||
# t/lib/bash/log_warn_die.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -64,10 +64,10 @@ _d () {
|
||||
# ###########################################################################
|
||||
# parse_options package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/parse_options.sh
|
||||
# t/lib/bash/parse_options.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ _eval_po() {
|
||||
*)
|
||||
echo "Invalid attribute in $opt_spec: $line" >&2
|
||||
exit 1
|
||||
esac
|
||||
esac
|
||||
done < "$opt_spec"
|
||||
|
||||
if [ -z "$opt" ]; then
|
||||
@@ -413,7 +413,6 @@ _parse_command_line() {
|
||||
else
|
||||
spec=$(grep "^short form:-$opt\$" "$PT_TMPDIR"/po/* | cut -d ':' -f 1)
|
||||
if [ -z "$spec" ]; then
|
||||
option_error "Unknown option: $real_opt"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
@@ -429,7 +428,7 @@ _parse_command_line() {
|
||||
if [ "$val" ]; then
|
||||
option_error "Option $real_opt does not take a value"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
if [ "$opt_is_negated" ]; then
|
||||
val=""
|
||||
else
|
||||
@@ -472,10 +471,10 @@ size_to_bytes() {
|
||||
# ###########################################################################
|
||||
# tmpdir package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/tmpdir.sh
|
||||
# t/lib/bash/tmpdir.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -513,10 +512,10 @@ rm_tmpdir() {
|
||||
# ###########################################################################
|
||||
# alt_cmds package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/alt_cmds.sh
|
||||
# t/lib/bash/alt_cmds.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -560,10 +559,10 @@ _which() {
|
||||
# ###########################################################################
|
||||
# summary_common package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/summary_common.sh
|
||||
# t/lib/bash/summary_common.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -690,10 +689,10 @@ get_var () {
|
||||
# ###########################################################################
|
||||
# report_formatting package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/report_formatting.sh
|
||||
# t/lib/bash/report_formatting.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -782,10 +781,10 @@ group_concat () {
|
||||
# ###########################################################################
|
||||
# collect_system_info package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/collect_system_info.sh
|
||||
# t/lib/bash/collect_system_info.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
@@ -860,6 +859,7 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
[ "$CMD_DMIDECODE" ] && $CMD_DMIDECODE > "$data_dir/dmidecode" 2>/dev/null
|
||||
|
||||
find_memory_stats "$platform" > "$data_dir/memory"
|
||||
find_numa_stats > "$data_dir/numactl"
|
||||
[ "$OPT_SUMMARIZE_MOUNTS" ] && mounted_fs_info "$platform" > "$data_dir/mounted_fs"
|
||||
raid_controller "$data_dir/dmesg_file" "$data_dir/lspci_file" >> "$data_dir/summary"
|
||||
|
||||
@@ -888,7 +888,7 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
fi
|
||||
|
||||
fio_status_minus_a "$data_dir/fusion-io_card"
|
||||
|
||||
|
||||
for file in $data_dir/*; do
|
||||
[ "$file" = "vmstat" ] && continue
|
||||
[ ! -s "$file" ] && rm "$file"
|
||||
@@ -925,7 +925,7 @@ fio_status_minus_a () {
|
||||
|
||||
print "${adapter}_general $adapter_general";
|
||||
print "${adapter}_modules @connected_modules";
|
||||
|
||||
|
||||
for my $module (@connected_modules) {
|
||||
my ($rest, $attached, $general, $firmware, $temperature, $media_status) = /(
|
||||
^ \s* $module \s+ (Attached[^\n]+) \n
|
||||
@@ -946,7 +946,7 @@ fio_status_minus_a () {
|
||||
} while <>;
|
||||
|
||||
print "adapters @adapters\n";
|
||||
|
||||
|
||||
exit;
|
||||
EOP
|
||||
|
||||
@@ -976,6 +976,12 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
echo "dirtystatus $(awk '/vm.dirty_bytes/{print $3}' "$data_dir/sysctl"), $(awk '/vm.dirty_background_bytes/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$data_dir/numactl" ]; then
|
||||
echo "numa-available $(awk '/available/{print $2}' "$data_dir/numactl")" >> "$data_dir/summary"
|
||||
echo "numa-policy $(awk '/policy/{print $2}' "$data_dir/numactl")" >> "$data_dir/summary"
|
||||
echo "numa-preferred-node $(awk '/preferred node/{print $3}' "$data_dir/numactl")" >> "$data_dir/summary"
|
||||
fi
|
||||
|
||||
schedulers_and_queue_size "$data_dir/summary" > "$data_dir/partitioning"
|
||||
|
||||
@@ -1174,13 +1180,20 @@ find_memory_stats () { local PTFUNCNAME=find_memory_stats;
|
||||
local platform="$1"
|
||||
|
||||
if [ "${platform}" = "Linux" ]; then
|
||||
free -bw
|
||||
free -b
|
||||
cat /proc/meminfo
|
||||
elif [ "${platform}" = "SunOS" ]; then
|
||||
$CMD_PRTCONF | awk -F: '/Memory/{print $2}'
|
||||
fi
|
||||
}
|
||||
|
||||
find_numa_stats () { local PTFUNCNAME=find_numa_stats;
|
||||
if command -v numactl >/dev/null; then
|
||||
numactl --hardware
|
||||
numactl --show
|
||||
fi
|
||||
}
|
||||
|
||||
mounted_fs_info () { local PTFUNCNAME=mounted_fs_info;
|
||||
local platform="$1"
|
||||
|
||||
@@ -1278,7 +1291,7 @@ top_processes () { local PTFUNCNAME=top_processes;
|
||||
|
||||
notable_processes_info () { local PTFUNCNAME=notable_processes_info;
|
||||
local format="%5s %+2d %s\n"
|
||||
local sshd_pid=$(ps -eo pid,args | awk '$0 ~ /\/usr\/sbin\/sshd/ { print $1; exit }')
|
||||
local sshd_pid=$(ps -eo pid,args | awk '$2 ~ /\/usr\/sbin\/sshd/ { print $1; exit }')
|
||||
|
||||
echo " PID OOM COMMAND"
|
||||
|
||||
@@ -1304,7 +1317,7 @@ processor_info () { local PTFUNCNAME=processor_info;
|
||||
cat /proc/cpuinfo > "$data_dir/proc_cpuinfo_copy" 2>/dev/null
|
||||
elif [ "${platform}" = "SunOS" ]; then
|
||||
$CMD_PSRINFO -v > "$data_dir/psrinfo_minus_v"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
propietary_raid_controller () { local PTFUNCNAME=propietary_raid_controller;
|
||||
@@ -1327,7 +1340,7 @@ propietary_raid_controller () { local PTFUNCNAME=propietary_raid_controller;
|
||||
echo "internal::raid_opt 2" >> "$variable_file"
|
||||
fi
|
||||
elif [ "${controller}" = "LSI Logic MegaRAID SAS" ]; then
|
||||
if [ -z "$CMD_MEGACLI64" ]; then
|
||||
if [ -z "$CMD_MEGACLI64" ]; then
|
||||
notfound="your package repository or the manufacturer's website"
|
||||
else
|
||||
echo "internal::raid_opt 3" >> "$variable_file"
|
||||
@@ -1351,16 +1364,16 @@ propietary_raid_controller () { local PTFUNCNAME=propietary_raid_controller;
|
||||
# ###########################################################################
|
||||
# report_system_info package
|
||||
# This package is a copy without comments from the original. The original
|
||||
# with comments and its test file can be found in the Bazaar repository at,
|
||||
# with comments and its test file can be found in the GitHub repository at,
|
||||
# lib/bash/report_system_info.sh
|
||||
# t/lib/bash/report_system_info.sh
|
||||
# See https://launchpad.net/percona-toolkit for more information.
|
||||
# See https://github.com/percona/percona-toolkit for more information.
|
||||
# ###########################################################################
|
||||
|
||||
|
||||
set -u
|
||||
|
||||
|
||||
|
||||
parse_proc_cpuinfo () { local PTFUNCNAME=parse_proc_cpuinfo;
|
||||
local file="$1"
|
||||
local virtual="$(grep -c ^processor "${file}")";
|
||||
@@ -1521,6 +1534,27 @@ parse_dmidecode_mem_devices () { local PTFUNCNAME=parse_dmidecode_mem_devices;
|
||||
| awk -F'|' '{printf(" %-9s %-8s %-17s %-13s %-13s %-8s\n", $4, $2, $7, $3, $5, $6);}'
|
||||
}
|
||||
|
||||
parse_numactl () { local PTFUNCNAME=parse_numactl;
|
||||
local file="$1"
|
||||
|
||||
[ -e "$file" ] || return
|
||||
|
||||
echo " Node Size Free CPUs"
|
||||
echo " ==== ==== ==== ===="
|
||||
|
||||
sed -n -e 's/node /node/g' \
|
||||
-e '/node[[:digit:]]/p' \
|
||||
"${file}" \
|
||||
| sort -r \
|
||||
| awk '$1 == cnode {
|
||||
if (NF > 4) { for(i=3;i<=NF;i++){printf("%s ", $i)} printf "\n" }
|
||||
else { printf("%-12s", $3" "$4); }
|
||||
}
|
||||
$1 != cnode { cnode = $1; printf(" %-8s", $1); printf("%-12s", $3" "$4); }'
|
||||
|
||||
echo
|
||||
}
|
||||
|
||||
parse_ip_s_link () { local PTFUNCNAME=parse_ip_s_link;
|
||||
local file="$1"
|
||||
|
||||
@@ -2045,6 +2079,9 @@ section_Memory () {
|
||||
local platform="$1"
|
||||
local data_dir="$2"
|
||||
|
||||
local name_val_len_orig=$NAME_VAL_LEN;
|
||||
local NAME_VAL_LEN=14
|
||||
|
||||
section "Memory"
|
||||
if [ "${platform}" = "Linux" ]; then
|
||||
parse_free_minus_b "$data_dir/memory"
|
||||
@@ -2070,6 +2107,16 @@ section_Memory () {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -s "$data_dir/numactl" ]; then
|
||||
name_val "Numa Nodes" "$(get_var "numa-available" "$data_dir/summary")"
|
||||
name_val "Numa Policy" "$(get_var "numa-policy" "$data_dir/summary")"
|
||||
name_val "Preferred Node" "$(get_var "numa-preferred-node" "$data_dir/summary")"
|
||||
|
||||
parse_numactl "$data_dir/numactl"
|
||||
fi
|
||||
|
||||
local NAME_VAL_LEN=$name_val_len_orig;
|
||||
|
||||
if [ -s "$data_dir/dmidecode" ]; then
|
||||
parse_dmidecode_mem_devices "$data_dir/dmidecode"
|
||||
fi
|
||||
@@ -2091,7 +2138,7 @@ report_fio_minus_a () {
|
||||
local file="$1"
|
||||
|
||||
name_val "fio Driver" "$(get_var driver_version "$file")"
|
||||
|
||||
|
||||
local adapters="$( get_var "adapters" "$file" )"
|
||||
for adapter in $( echo $adapters | awk '{for (i=1; i<=NF; i++) print $i;}' ); do
|
||||
local adapter_for_output="$(echo "$adapter" | sed 's/::[0-9]*$//' | tr ':' ' ')"
|
||||
@@ -2161,7 +2208,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
section "Fusion-io Card"
|
||||
report_fio_minus_a "$data_dir/fusion-io_card"
|
||||
fi
|
||||
|
||||
|
||||
if [ -s "$data_dir/mounted_fs" ]; then
|
||||
section "Mounted Filesystems"
|
||||
parse_filesystems "$data_dir/mounted_fs" "${platform}"
|
||||
@@ -2253,23 +2300,17 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
|
||||
section "Memory management"
|
||||
report_transparent_huge_pages
|
||||
|
||||
section "The End"
|
||||
}
|
||||
|
||||
report_transparent_huge_pages () {
|
||||
|
||||
STATUS_THP_SYSTEM=""
|
||||
if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
|
||||
CONTENT_TRANSHP=$(cat /sys/kernel/mm/transparent_hugepage/enabled)
|
||||
STATUS_THP_SYSTEM=$(echo $CONTENT_TRANSHP | grep -cv '\[never\]')
|
||||
elif [ -f /sys/kernel/mm/redhat_transparent_hugepage/enabled ]; then
|
||||
CONTENT_TRANSHP=$(</sys/kernel/mm/redhat_transparent_hugepage/enabled)
|
||||
CONTENT_TRANSHP=$(</sys/kernel/mm/transparent_hugepage/enabled)
|
||||
STATUS_THP_SYSTEM=$(echo $CONTENT_TRANSHP | grep -cv '\[never\]')
|
||||
fi
|
||||
|
||||
if [ -z $STATUS_THP_SYSTEM ]; then
|
||||
echo "Unable to get Transparent huge pages status."
|
||||
elif [ $STATUS_THP_SYSTEM = 0 ]; then
|
||||
if [ $STATUS_THP_SYSTEM = 0 ]; then
|
||||
echo "Transparent huge pages are currently disabled on the system."
|
||||
else
|
||||
echo "Transparent huge pages are enabled."
|
||||
@@ -2277,7 +2318,6 @@ report_transparent_huge_pages () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
# ###########################################################################
|
||||
# End report_system_info package
|
||||
# ###########################################################################
|
||||
|
||||
Reference in New Issue
Block a user