mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 21:19:59 +00:00
pt-summary shouldn't leave empty files; both summary tools should
die if passed a --save-samples directory that has files in it.
This commit is contained in:
@@ -708,6 +708,8 @@ setup_data_dir () {
|
||||
else
|
||||
if [ ! -d "$OPT_SAVE_DATA" ]; then
|
||||
mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA"
|
||||
elif [ "$( ls "$OPT_SAVE_DATA" )" != "0" ]; then
|
||||
die "--save-samples directory isn't empty, halting."
|
||||
fi
|
||||
touch "$OPT_SAVE_DATA/test" || die "Cannot write to $OPT_SAVE_DATA"
|
||||
rm "$OPT_SAVE_DATA/test" || die "Cannot rm $OPT_SAVE_DATA/test"
|
||||
|
@@ -625,6 +625,8 @@ setup_data_dir () {
|
||||
else
|
||||
if [ ! -d "$OPT_SAVE_DATA" ]; then
|
||||
mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA"
|
||||
elif [ "$( ls "$OPT_SAVE_DATA" )" != "0" ]; then
|
||||
die "--save-samples directory isn't empty, halting."
|
||||
fi
|
||||
touch "$OPT_SAVE_DATA/test" || die "Cannot write to $OPT_SAVE_DATA"
|
||||
rm "$OPT_SAVE_DATA/test" || die "Cannot rm $OPT_SAVE_DATA/test"
|
||||
@@ -771,6 +773,7 @@ setup_commands () {
|
||||
CMD_PSRINFO="$( _which psrinfo 2>/dev/null )"
|
||||
CMD_SWAPCTL="$( _which swapctl 2>/dev/null )"
|
||||
CMD_LSB_RELEASE="$( _which lsb_release 2>/dev/null )"
|
||||
CMD_ETHTOOL="$( _which ethtool 2>/dev/null )"
|
||||
}
|
||||
|
||||
collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
@@ -787,15 +790,15 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
fi
|
||||
|
||||
local platform="$(uname -s)"
|
||||
echo "platform $platform" >> "$data_dir/summary"
|
||||
echo "platform $platform" >> "$data_dir/summary"
|
||||
echo "hostname $(uname -n)" >> "$data_dir/summary"
|
||||
uptime >> "$data_dir/uptime"
|
||||
|
||||
processor_info "$data_dir"
|
||||
find_release_and_kernel "$platform" >> "$data_dir/summary"
|
||||
cpu_and_os_arch "$platform" >> "$data_dir/summary"
|
||||
cpu_and_os_arch "$platform" >> "$data_dir/summary"
|
||||
find_virtualization "$platform" "$data_dir/dmesg_file" "$data_dir/lspci_file" >> "$data_dir/summary"
|
||||
dmidecode_system_info >> "$data_dir/summary"
|
||||
dmidecode_system_info >> "$data_dir/summary"
|
||||
|
||||
if [ "${platform}" = "SunOS" -a "${CMD_ZONENAME}" ]; then
|
||||
echo "zonename $($CMD_ZONENAME)" >> "$data_dir/summary"
|
||||
@@ -819,7 +822,10 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
|
||||
[ "${platform}" = "Linux" ] && linux_exclusive_collection "$data_dir"
|
||||
|
||||
[ "$CMD_IP" -a "$OPT_SUMMARIZE_NETWORK" ] && $CMD_IP -s link > "$data_dir/ip"
|
||||
if [ "$CMD_IP" -a "$OPT_SUMMARIZE_NETWORK" ]; then
|
||||
$CMD_IP -s link > "$data_dir/ip"
|
||||
network_device_info "$data_dir/ip" > "$data_dir/network_devices"
|
||||
fi
|
||||
|
||||
[ "$CMD_SWAPCTL" ] && $CMD_SWAPCTL -s > "$data_dir/swapctl"
|
||||
|
||||
@@ -834,6 +840,11 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
) &
|
||||
fi
|
||||
fi
|
||||
|
||||
for file in $data_dir/*; do
|
||||
[ "$file" = "vmstat" ] && continue
|
||||
[ ! -s "$file" ] && rm "$file"
|
||||
done
|
||||
}
|
||||
|
||||
linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
@@ -842,7 +853,7 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
echo "threading $(getconf GNU_LIBPTHREAD_VERSION)" >> "$data_dir/summary"
|
||||
|
||||
local getenforce=""
|
||||
[ "$CMD_GETENFORCE" ] && $CMD_GETENFORCE 2>&1
|
||||
[ "$CMD_GETENFORCE" ] && getenforce="$($CMD_GETENFORCE 2>&1)"
|
||||
echo "getenforce ${getenforce:-"No SELinux detected"}" >> "$data_dir/summary"
|
||||
|
||||
echo "swappiness $(awk '/vm.swappiness/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary"
|
||||
@@ -864,7 +875,7 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
echo "${file} $(cat /proc/sys/fs/${file} 2>&1)" >> "$data_dir/summary"
|
||||
done
|
||||
|
||||
[ "$CMD_LVS" -a -x "$CMD_LVS" ] && $CMD_LVS 1>"$data_dir/lvs" 2>&1
|
||||
[ "$CMD_LVS" -a -x "$CMD_LVS" ] && $CMD_LVS 1>"$data_dir/lvs" 2>"$data_dir/lvs.stderr"
|
||||
|
||||
[ "$CMD_VGS" -a -x "$CMD_VGS" ] && \
|
||||
$CMD_VGS -o vg_name,vg_size,vg_free 2>/dev/null > "$data_dir/vgs"
|
||||
@@ -873,6 +884,24 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
$CMD_NETSTAT -antp > "$data_dir/netstat" 2>/dev/null
|
||||
}
|
||||
|
||||
network_device_info () {
|
||||
local ip_minus_s_file="$1"
|
||||
|
||||
if [ "$CMD_ETHTOOL" ]; then
|
||||
local tempfile="$TMPDIR/ethtool_output_temp"
|
||||
for device in $( awk '/^[1-9]/{ print $2 }' "$ip_minus_s_file" \
|
||||
| awk -F: '{print $1}' \
|
||||
| grep -v '^lo\|^in\|^gr' \
|
||||
| sort -u ); do
|
||||
ethtool $device > "$tempfile" 2>/dev/null
|
||||
|
||||
if ! grep -q 'No data available' "$tempfile"; then
|
||||
cat "$tempfile"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
find_release_and_kernel () { local PTFUNCNAME=find_release_and_kernel;
|
||||
local platform="$1"
|
||||
|
||||
@@ -1405,6 +1434,34 @@ parse_ip_s_link () { local PTFUNCNAME=parse_ip_s_link;
|
||||
}" "$file"
|
||||
}
|
||||
|
||||
parse_ethtool () {
|
||||
local file="$1"
|
||||
|
||||
[ -e "$file" ] || return
|
||||
|
||||
echo " Device Speed Duplex"
|
||||
echo " ========= ========= ========="
|
||||
|
||||
|
||||
awk '
|
||||
/^Setting for / {
|
||||
device = $3;
|
||||
device_names[device] = device;
|
||||
}
|
||||
/Speed:/ { devices[device, ",speed"] = $2 }
|
||||
/Duplex:/ { devices[device, ",duplex"] = $2 }
|
||||
END {
|
||||
for ( device in device_names ) {
|
||||
printf(" %-10s %-10s %-10s",
|
||||
device,
|
||||
devices[device ",speed"],
|
||||
devices[device ",duplex"]);
|
||||
}
|
||||
}
|
||||
' "$file"
|
||||
|
||||
}
|
||||
|
||||
parse_netstat () { local PTFUNCNAME=parse_netstat;
|
||||
local file="$1"
|
||||
|
||||
@@ -1694,6 +1751,7 @@ parse_lsi_megaraid_bbu_status () { local PTFUNCNAME=parse_lsi_megaraid_bbu_statu
|
||||
format_lvs () { local PTFUNCNAME=format_lvs;
|
||||
local lvs_file="$1"
|
||||
local vgs_file="$2"
|
||||
local lvs_errors="$3"
|
||||
|
||||
if [ -e "$lvs_file" -a -e "$vgs_file" ]; then
|
||||
local header="$(head -n1 "$lvs_file")$(head -n1 "$vgs_file" | sed -e 's/^ *VG//')"
|
||||
@@ -1713,6 +1771,9 @@ format_lvs () { local PTFUNCNAME=format_lvs;
|
||||
else
|
||||
if [ -e "$lvs_file" ]; then
|
||||
cat "$lvs_file"
|
||||
elif [ -e "$lvs_errors" ]; then
|
||||
echo "lvs didn't output anything and had the following errors:"
|
||||
cat "$lvs_errors"
|
||||
else
|
||||
echo "Cannot execute 'lvs'";
|
||||
fi
|
||||
@@ -1922,6 +1983,18 @@ section_Memory () {
|
||||
fi
|
||||
}
|
||||
|
||||
parse_uptime () {
|
||||
local file="$1"
|
||||
|
||||
awk ' / up / {
|
||||
printf substr($0, index($0, " up ")+4 );
|
||||
}
|
||||
!/ up / {
|
||||
printf $0;
|
||||
}
|
||||
' "$file"
|
||||
}
|
||||
|
||||
report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
local data_dir="$1"
|
||||
|
||||
@@ -1934,7 +2007,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
local platform="$(get_var "platform" "$data_dir/summary")"
|
||||
name_val "Date" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)"
|
||||
name_val "Hostname" "$(get_var hostname "$data_dir/summary")"
|
||||
name_val "Uptime" "$(cat "$data_dir/uptime")"
|
||||
name_val "Uptime" "$(parse_uptime "$data_dir/uptime")"
|
||||
|
||||
if [ "$(get_var "vendor" "$data_dir/summary")" ]; then
|
||||
name_val "System" "$(get_var "system" "$data_dir/summary")";
|
||||
@@ -1988,7 +2061,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
done
|
||||
|
||||
section "LVM_Volumes"
|
||||
format_lvs "$data_dir/lvs" "$data_dir/vgs"
|
||||
format_lvs "$data_dir/lvs" "$data_dir/vgs" "$data_dir/lvs.stderr"
|
||||
fi
|
||||
|
||||
section "RAID_Controller"
|
||||
@@ -2035,6 +2108,11 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
parse_ip_s_link "$data_dir/ip"
|
||||
fi
|
||||
|
||||
if [ -s "$data_dir/network_devices" ]; then
|
||||
section "Network_Devices"
|
||||
parse_ethtool "$data_dir/network_devices"
|
||||
fi
|
||||
|
||||
if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then
|
||||
section "Network_Connections"
|
||||
parse_netstat "$data_dir/netstat"
|
||||
@@ -2113,6 +2191,7 @@ if [ "${0##*/}" = "$TOOL" ] \
|
||||
if [ $po_status -ne 0 ]; then
|
||||
exit $po_status
|
||||
fi
|
||||
|
||||
main "$@"
|
||||
fi
|
||||
|
||||
|
@@ -54,6 +54,7 @@ setup_commands () {
|
||||
CMD_PSRINFO="$( _which psrinfo 2>/dev/null )"
|
||||
CMD_SWAPCTL="$( _which swapctl 2>/dev/null )"
|
||||
CMD_LSB_RELEASE="$( _which lsb_release 2>/dev/null )"
|
||||
CMD_ETHTOOL="$( _which ethtool 2>/dev/null )"
|
||||
}
|
||||
|
||||
collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
@@ -73,15 +74,15 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
fi
|
||||
|
||||
local platform="$(uname -s)"
|
||||
echo "platform $platform" >> "$data_dir/summary"
|
||||
echo "platform $platform" >> "$data_dir/summary"
|
||||
echo "hostname $(uname -n)" >> "$data_dir/summary"
|
||||
uptime >> "$data_dir/uptime"
|
||||
|
||||
processor_info "$data_dir"
|
||||
find_release_and_kernel "$platform" >> "$data_dir/summary"
|
||||
cpu_and_os_arch "$platform" >> "$data_dir/summary"
|
||||
cpu_and_os_arch "$platform" >> "$data_dir/summary"
|
||||
find_virtualization "$platform" "$data_dir/dmesg_file" "$data_dir/lspci_file" >> "$data_dir/summary"
|
||||
dmidecode_system_info >> "$data_dir/summary"
|
||||
dmidecode_system_info >> "$data_dir/summary"
|
||||
|
||||
if [ "${platform}" = "SunOS" -a "${CMD_ZONENAME}" ]; then
|
||||
echo "zonename $($CMD_ZONENAME)" >> "$data_dir/summary"
|
||||
@@ -106,7 +107,10 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
|
||||
[ "${platform}" = "Linux" ] && linux_exclusive_collection "$data_dir"
|
||||
|
||||
[ "$CMD_IP" -a "$OPT_SUMMARIZE_NETWORK" ] && $CMD_IP -s link > "$data_dir/ip"
|
||||
if [ "$CMD_IP" -a "$OPT_SUMMARIZE_NETWORK" ]; then
|
||||
$CMD_IP -s link > "$data_dir/ip"
|
||||
network_device_info "$data_dir/ip" > "$data_dir/network_devices"
|
||||
fi
|
||||
|
||||
[ "$CMD_SWAPCTL" ] && $CMD_SWAPCTL -s > "$data_dir/swapctl"
|
||||
|
||||
@@ -126,6 +130,13 @@ collect_system_data () { local PTFUNCNAME=collect_system_data;
|
||||
) &
|
||||
fi
|
||||
fi
|
||||
|
||||
# Clean the data directory, don't leave empty files
|
||||
for file in $data_dir/*; do
|
||||
# The vmstat file gets special treatmeant, see above.
|
||||
[ "$file" = "vmstat" ] && continue
|
||||
[ ! -s "$file" ] && rm "$file"
|
||||
done
|
||||
}
|
||||
|
||||
linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
@@ -134,7 +145,7 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
echo "threading $(getconf GNU_LIBPTHREAD_VERSION)" >> "$data_dir/summary"
|
||||
|
||||
local getenforce=""
|
||||
[ "$CMD_GETENFORCE" ] && $CMD_GETENFORCE 2>&1
|
||||
[ "$CMD_GETENFORCE" ] && getenforce="$($CMD_GETENFORCE 2>&1)"
|
||||
echo "getenforce ${getenforce:-"No SELinux detected"}" >> "$data_dir/summary"
|
||||
|
||||
echo "swappiness $(awk '/vm.swappiness/{print $3}' "$data_dir/sysctl")" >> "$data_dir/summary"
|
||||
@@ -156,7 +167,7 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
echo "${file} $(cat /proc/sys/fs/${file} 2>&1)" >> "$data_dir/summary"
|
||||
done
|
||||
|
||||
[ "$CMD_LVS" -a -x "$CMD_LVS" ] && $CMD_LVS 1>"$data_dir/lvs" 2>&1
|
||||
[ "$CMD_LVS" -a -x "$CMD_LVS" ] && $CMD_LVS 1>"$data_dir/lvs" 2>"$data_dir/lvs.stderr"
|
||||
|
||||
[ "$CMD_VGS" -a -x "$CMD_VGS" ] && \
|
||||
$CMD_VGS -o vg_name,vg_size,vg_free 2>/dev/null > "$data_dir/vgs"
|
||||
@@ -165,6 +176,31 @@ linux_exclusive_collection () { local PTFUNCNAME=linux_exclusive_collection;
|
||||
$CMD_NETSTAT -antp > "$data_dir/netstat" 2>/dev/null
|
||||
}
|
||||
|
||||
network_device_info () {
|
||||
local ip_minus_s_file="$1"
|
||||
|
||||
if [ "$CMD_ETHTOOL" ]; then
|
||||
local tempfile="$TMPDIR/ethtool_output_temp"
|
||||
# For each entry in the ip -s link dump, check if itu starts with a number.
|
||||
# If it does, print the second field. Then remove the colon and everything
|
||||
# following that. Then skip what are usually interfaces.
|
||||
for device in $( awk '/^[1-9]/{ print $2 }' "$ip_minus_s_file" \
|
||||
| awk -F: '{print $1}' \
|
||||
| grep -v '^lo\|^in\|^gr' \
|
||||
| sort -u ); do
|
||||
# Call ethtool on what might be a device
|
||||
ethtool $device > "$tempfile" 2>/dev/null
|
||||
|
||||
# If there isn't any information, we are most likely not dealing with
|
||||
# a device at all, but an interface, so skip it, otherwise print
|
||||
# ethtool's output.
|
||||
if ! grep -q 'No data available' "$tempfile"; then
|
||||
cat "$tempfile"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Try to find all sorts of different files that say what the release is.
|
||||
find_release_and_kernel () { local PTFUNCNAME=find_release_and_kernel;
|
||||
local platform="$1"
|
||||
|
@@ -267,6 +267,37 @@ parse_ip_s_link () { local PTFUNCNAME=parse_ip_s_link;
|
||||
}" "$file"
|
||||
}
|
||||
|
||||
# ##############################################################################
|
||||
# Parse the output of 'ethtool DEVICE'
|
||||
# ##############################################################################
|
||||
parse_ethtool () {
|
||||
local file="$1"
|
||||
|
||||
[ -e "$file" ] || return
|
||||
|
||||
echo " Device Speed Duplex"
|
||||
echo " ========= ========= ========="
|
||||
|
||||
|
||||
awk '
|
||||
/^Setting for / {
|
||||
device = $3;
|
||||
device_names[device] = device;
|
||||
}
|
||||
/Speed:/ { devices[device, ",speed"] = $2 }
|
||||
/Duplex:/ { devices[device, ",duplex"] = $2 }
|
||||
END {
|
||||
for ( device in device_names ) {
|
||||
printf(" %-10s %-10s %-10s",
|
||||
device,
|
||||
devices[device ",speed"],
|
||||
devices[device ",duplex"]);
|
||||
}
|
||||
}
|
||||
' "$file"
|
||||
|
||||
}
|
||||
|
||||
# ##############################################################################
|
||||
# Parse the output of 'netstat -antp'
|
||||
# ##############################################################################
|
||||
@@ -605,6 +636,7 @@ parse_lsi_megaraid_bbu_status () { local PTFUNCNAME=parse_lsi_megaraid_bbu_statu
|
||||
format_lvs () { local PTFUNCNAME=format_lvs;
|
||||
local lvs_file="$1"
|
||||
local vgs_file="$2"
|
||||
local lvs_errors="$3"
|
||||
|
||||
if [ -e "$lvs_file" -a -e "$vgs_file" ]; then
|
||||
local header="$(head -n1 "$lvs_file")$(head -n1 "$vgs_file" | sed -e 's/^ *VG//')"
|
||||
@@ -624,6 +656,9 @@ format_lvs () { local PTFUNCNAME=format_lvs;
|
||||
else
|
||||
if [ -e "$lvs_file" ]; then
|
||||
cat "$lvs_file"
|
||||
elif [ -e "$lvs_errors" ]; then
|
||||
echo "lvs didn't output anything and had the following errors:"
|
||||
cat "$lvs_errors"
|
||||
else
|
||||
echo "Cannot execute 'lvs'";
|
||||
fi
|
||||
@@ -860,6 +895,18 @@ section_Memory () {
|
||||
fi
|
||||
}
|
||||
|
||||
parse_uptime () {
|
||||
local file="$1"
|
||||
|
||||
awk ' / up / {
|
||||
printf substr($0, index($0, " up ")+4 );
|
||||
}
|
||||
!/ up / {
|
||||
printf $0;
|
||||
}
|
||||
' "$file"
|
||||
}
|
||||
|
||||
# The sum of all of the above
|
||||
report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
local data_dir="$1"
|
||||
@@ -876,7 +923,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
local platform="$(get_var "platform" "$data_dir/summary")"
|
||||
name_val "Date" "`date -u +'%F %T UTC'` (local TZ: `date +'%Z %z'`)"
|
||||
name_val "Hostname" "$(get_var hostname "$data_dir/summary")"
|
||||
name_val "Uptime" "$(cat "$data_dir/uptime")"
|
||||
name_val "Uptime" "$(parse_uptime "$data_dir/uptime")"
|
||||
|
||||
if [ "$(get_var "vendor" "$data_dir/summary")" ]; then
|
||||
name_val "System" "$(get_var "system" "$data_dir/summary")";
|
||||
@@ -937,7 +984,7 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
done
|
||||
|
||||
section "LVM_Volumes"
|
||||
format_lvs "$data_dir/lvs" "$data_dir/vgs"
|
||||
format_lvs "$data_dir/lvs" "$data_dir/vgs" "$data_dir/lvs.stderr"
|
||||
fi
|
||||
|
||||
section "RAID_Controller"
|
||||
@@ -993,6 +1040,11 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
parse_ip_s_link "$data_dir/ip"
|
||||
fi
|
||||
|
||||
if [ -s "$data_dir/network_devices" ]; then
|
||||
section "Network_Devices"
|
||||
parse_ethtool "$data_dir/network_devices"
|
||||
fi
|
||||
|
||||
if [ "${platform}" = "Linux" -a -e "$data_dir/netstat" ]; then
|
||||
section "Network_Connections"
|
||||
parse_netstat "$data_dir/netstat"
|
||||
|
@@ -133,6 +133,8 @@ setup_data_dir () {
|
||||
# Check the user's --save-data dir.
|
||||
if [ ! -d "$OPT_SAVE_DATA" ]; then
|
||||
mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA"
|
||||
elif [ "$( ls "$OPT_SAVE_DATA" )" != "0" ]; then
|
||||
die "--save-samples directory isn't empty, halting."
|
||||
fi
|
||||
touch "$OPT_SAVE_DATA/test" || die "Cannot write to $OPT_SAVE_DATA"
|
||||
rm "$OPT_SAVE_DATA/test" || die "Cannot rm $OPT_SAVE_DATA/test"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
plan 39
|
||||
plan 40
|
||||
|
||||
TMPDIR="$TEST_TMPDIR"
|
||||
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
|
||||
@@ -25,6 +25,13 @@ setup_commands
|
||||
|
||||
collect_system_data "$p"
|
||||
|
||||
p2="$TMPDIR/collect_mysql_info2"
|
||||
mkdir "$p2"
|
||||
touch "$p2/some_empty_file"
|
||||
collect_system_data "$p2"
|
||||
|
||||
cmd_ok "test ! -e \"$p2/some_empty_file\"" "collect_system_data removes empty files before exiting"
|
||||
|
||||
cat <<EOF > "$TMPDIR/expected"
|
||||
Fusion-MPT SAS
|
||||
EOF
|
||||
@@ -181,7 +188,7 @@ test_linux_exclusive_collection () {
|
||||
|
||||
is \
|
||||
"$(ls "${dir}/2" | grep 'lvs\|vgs\|netstat' | sort | xargs echo )" \
|
||||
"lvs netstat vgs" \
|
||||
"lvs lvs.stderr netstat vgs" \
|
||||
"linux_exclusive_collection: And works as expected if they are there"
|
||||
|
||||
local i=1
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
plan 42
|
||||
plan 44
|
||||
|
||||
. "$LIB_DIR/alt_cmds.sh"
|
||||
. "$LIB_DIR/log_warn_die.sh"
|
||||
@@ -1154,6 +1154,24 @@ EOF
|
||||
parse_arcconf "$samples/arcconf-003_900285.txt" > "$TMPDIR/got"
|
||||
no_diff "$TMPDIR/got" "$TMPDIR/expected" "Bug 900285"
|
||||
|
||||
# parse_uptime
|
||||
|
||||
cat <<EOF > "$TMPDIR/in"
|
||||
15:10:14 up 1 day, 15:08, 11 users, load average: 0.18, 0.09, 0.08
|
||||
EOF
|
||||
is \
|
||||
"$( parse_uptime "$TMPDIR/in" )" \
|
||||
"1 day, 15:08, 11 users, load average: 0.18, 0.09, 0.08" \
|
||||
"parse_uptime works with Ubuntu's uptime"
|
||||
|
||||
cat <<EOF > "$TMPDIR/in"
|
||||
some weird format etc 1 day, 15:08, 11 users, load average: 0.18, 0.09, 0.08
|
||||
EOF
|
||||
is \
|
||||
"$( parse_uptime "$TMPDIR/in" )" \
|
||||
" some weird format etc 1 day, 15:08, 11 users, load average: 0.18, 0.09, 0.08" \
|
||||
"parse_uptime returns uptime as-if if it doesn't contain an 'up'"
|
||||
|
||||
# report_system_summary
|
||||
parse_options "$BIN_DIR/pt-summary"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
plan 8
|
||||
plan 9
|
||||
|
||||
TMPDIR="$TEST_TMPDIR"
|
||||
PATH="$PATH:$PERCONA_TOOLKIT_SANDBOX/bin"
|
||||
@@ -58,3 +58,8 @@ is \
|
||||
"$(get_var "Open_tables" "$samples/temp002/mysql-status")" \
|
||||
"40" \
|
||||
"get_var works on a status dump"
|
||||
|
||||
|
||||
dies_ok \
|
||||
"setup_data_dir $PERCONA_TOOLKIT_BRANCH" \
|
||||
"setup_data_dir dies if passed a populated directory" 2>/dev/null
|
||||
|
@@ -13,7 +13,17 @@ use English qw(-no_match_vars);
|
||||
use PerconaTest;
|
||||
|
||||
my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
|
||||
push @ARGV, "$trunk/t/$tool/*.sh" unless @ARGV;
|
||||
system("$trunk/util/test-bash-functions $trunk/bin/$tool @ARGV");
|
||||
|
||||
use Test::More tests => 2;
|
||||
|
||||
for my $i (2..3) {
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
sub { print `$trunk/bin/pt-summary --read-samples "$trunk/t/pt-summary/samples/Linux/00$i/" | tail -n+3` },
|
||||
"t/pt-summary/samples/Linux/output_00$i.txt"),
|
||||
"--read-samples samples/Linux/00$i works"
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Hostname | localhost.localdomain
|
||||
Uptime | 03:34:31 up 38 min, 1 user, load average: 1.60, 1.03, 1.37
|
||||
Uptime | 38 min, 1 user, load average: 1.60, 1.03, 1.37
|
||||
Platform | Linux
|
||||
Release | CentOS release 5.7 (Final)
|
||||
Kernel | 2.6.18-274.el5
|
||||
|
@@ -1,5 +1,5 @@
|
||||
Hostname | localhost.localdomain
|
||||
Uptime | 03:31:47 up 35 min, 1 user, load average: 1.10, 0.62, 1.31
|
||||
Uptime | 35 min, 1 user, load average: 1.10, 0.62, 1.31
|
||||
Platform | Linux
|
||||
Release | CentOS release 5.7 (Final)
|
||||
Kernel | 2.6.18-274.el5
|
||||
|
@@ -183,6 +183,20 @@ cmd_ok() {
|
||||
result $? "$test_name"
|
||||
}
|
||||
|
||||
dies_ok() {
|
||||
local test_command=$1
|
||||
local test_name=${2:-""}
|
||||
|
||||
local result=1
|
||||
(
|
||||
eval $test_command
|
||||
) 2>/dev/null &
|
||||
wait $!
|
||||
[ $? ] && result=0
|
||||
|
||||
result $result "$test_name"
|
||||
}
|
||||
|
||||
# ############################################################################
|
||||
# Script starts here
|
||||
# ############################################################################
|
||||
|
Reference in New Issue
Block a user