mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
The previous merge went a bit wrong, and left the libraries unsynced with the tools; This commit fixes it.
This commit is contained in:
@@ -617,20 +617,20 @@ has_symbols () {
|
||||
}
|
||||
|
||||
setup_data_dir () {
|
||||
local OPT_SAVE_DATA="$1"
|
||||
local existing_dir="$1"
|
||||
local data_dir=""
|
||||
if [ -z "$OPT_SAVE_DATA" ]; then
|
||||
if [ -z "$existing_dir" ]; then
|
||||
mkdir "$TMPDIR/data" || die "Cannot mkdir $TMPDIR/data"
|
||||
data_dir="$TMPDIR/data"
|
||||
else
|
||||
if [ ! -d "$OPT_SAVE_DATA" ]; then
|
||||
mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA"
|
||||
elif [ "$( ls "$OPT_SAVE_DATA" | wc -l )" != "0" ]; then
|
||||
if [ ! -d "$existing_dir" ]; then
|
||||
mkdir "$existing_dir" || die "Cannot mkdir $existing_dir"
|
||||
elif [ "$( ls -A "$existing_dir" )" ]; 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"
|
||||
data_dir="$OPT_SAVE_DATA"
|
||||
touch "$existing_dir/test" || die "Cannot write to $existing_dir"
|
||||
rm "$existing_dir/test" || die "Cannot rm $existing_dir/test"
|
||||
data_dir="$existing_dir"
|
||||
fi
|
||||
echo "$data_dir"
|
||||
}
|
||||
@@ -638,7 +638,7 @@ setup_data_dir () {
|
||||
get_var () {
|
||||
local varname="$1"
|
||||
local file="$2"
|
||||
awk -v pattern="${varname}" '$1 == pattern { if (length($2)) { print substr($0, index($0,$2)) } }' "${file}"
|
||||
awk -v pattern="${varname}" '$1 == pattern { if (length($2)) { len = length($1); print substr($0, len+index(substr($0, len+1), $2)) } }' "${file}"
|
||||
}
|
||||
|
||||
# ###########################################################################
|
||||
|
@@ -634,34 +634,11 @@ parse_lsi_megaraid_bbu_status () { local PTFUNCNAME=parse_lsi_megaraid_bbu_statu
|
||||
# total and free space available to each volume.
|
||||
# ##############################################################################
|
||||
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//')"
|
||||
|
||||
echo "$header"
|
||||
tail -n+2 "$lvs_file" | while read lvs_line; do
|
||||
local current_vg="$(echo $lvs_line | awk '{print $2}')"
|
||||
while read vgs_line; do
|
||||
local current_vgs_vg="$(echo $vgs_line | awk '{print $1}' )"
|
||||
if [ "$current_vg" = "$current_vgs_vg" ]; then
|
||||
lvs_line="${lvs_line}$(echo $vgs_line | sed -e "s/^ *$current_vg//")"
|
||||
break
|
||||
fi
|
||||
done < "$vgs_file"
|
||||
echo $lvs_line
|
||||
done
|
||||
local file="$1"
|
||||
if [ -e "$file" ]; then
|
||||
grep -v "open failed" "$file"
|
||||
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
|
||||
echo "Unable to collect information";
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -984,7 +961,9 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
||||
done
|
||||
|
||||
section "LVM_Volumes"
|
||||
format_lvs "$data_dir/lvs" "$data_dir/vgs" "$data_dir/lvs.stderr"
|
||||
format_lvs "$data_dir/lvs"
|
||||
section "LVM_Volume_Groups"
|
||||
format_lvs "$data_dir/vgs"
|
||||
fi
|
||||
|
||||
section "RAID_Controller"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
plan 49
|
||||
plan 48
|
||||
|
||||
. "$LIB_DIR/alt_cmds.sh"
|
||||
. "$LIB_DIR/log_warn_die.sh"
|
||||
@@ -1267,21 +1267,16 @@ is \
|
||||
# parse_lvs
|
||||
|
||||
is \
|
||||
"$(format_lvs "" "" "")" \
|
||||
"Cannot execute 'lvs'" \
|
||||
"$(format_lvs "" "")" \
|
||||
"Unable to collect information" \
|
||||
"format_lvs has a meaningful error message if all goes wrong"
|
||||
|
||||
echo "There was an error..." > "$TMPDIR/in"
|
||||
like \
|
||||
"$(format_lvs "$TMPDIR/some_file_that_does_not_exist" "" "$TMPDIR/in")" \
|
||||
"lvs didn't output anything and had the following errors:" \
|
||||
"format_lvs shows the stderr of lvs if the lvs file doesn't exist"
|
||||
|
||||
echo "Pretending to be an lvs dump" > "$TMPDIR/in"
|
||||
is \
|
||||
"$(format_lvs "$TMPDIR/in" "" "")" \
|
||||
"$(format_lvs "$TMPDIR/in" "")" \
|
||||
"Pretending to be an lvs dump" \
|
||||
"format_lvs has a meaningful error message if all goes wrong"
|
||||
"format_lvs dumps the file passed in"
|
||||
|
||||
# report_system_summary
|
||||
parse_options "$BIN_DIR/pt-summary"
|
||||
@@ -1514,6 +1509,8 @@ dentry-state | 78471 67588 45 0 0 0
|
||||
inode-nr | 70996 10387
|
||||
# LVM Volumes ################################################
|
||||
No volume groups found
|
||||
# LVM Volume Groups ##########################################
|
||||
Unable to collect information
|
||||
# RAID Controller ############################################
|
||||
Controller | No RAID controller detected
|
||||
# Network Config #############################################
|
||||
|
@@ -45,7 +45,9 @@ dentry-state | 9392 7451 45 0 0 0
|
||||
file-nr | 640 0 102187
|
||||
inode-nr | 5431 148
|
||||
# LVM Volumes ################################################
|
||||
Cannot execute 'lvs'
|
||||
Unable to collect information
|
||||
# LVM Volume Groups ##########################################
|
||||
Unable to collect information
|
||||
# RAID Controller ############################################
|
||||
Controller | No RAID controller detected
|
||||
# Network Config #############################################
|
||||
|
@@ -42,7 +42,9 @@ dentry-state | 9175 7239 45 0 0 0
|
||||
file-nr | 640 0 102187
|
||||
inode-nr | 5259 148
|
||||
# LVM Volumes ################################################
|
||||
Cannot execute 'lvs'
|
||||
Unable to collect information
|
||||
# LVM Volume Groups ##########################################
|
||||
Unable to collect information
|
||||
# RAID Controller ############################################
|
||||
Controller | No RAID controller detected
|
||||
# Network Config #############################################
|
||||
|
Reference in New Issue
Block a user