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 () {
|
setup_data_dir () {
|
||||||
local OPT_SAVE_DATA="$1"
|
local existing_dir="$1"
|
||||||
local data_dir=""
|
local data_dir=""
|
||||||
if [ -z "$OPT_SAVE_DATA" ]; then
|
if [ -z "$existing_dir" ]; then
|
||||||
mkdir "$TMPDIR/data" || die "Cannot mkdir $TMPDIR/data"
|
mkdir "$TMPDIR/data" || die "Cannot mkdir $TMPDIR/data"
|
||||||
data_dir="$TMPDIR/data"
|
data_dir="$TMPDIR/data"
|
||||||
else
|
else
|
||||||
if [ ! -d "$OPT_SAVE_DATA" ]; then
|
if [ ! -d "$existing_dir" ]; then
|
||||||
mkdir "$OPT_SAVE_DATA" || die "Cannot mkdir $OPT_SAVE_DATA"
|
mkdir "$existing_dir" || die "Cannot mkdir $existing_dir"
|
||||||
elif [ "$( ls "$OPT_SAVE_DATA" | wc -l )" != "0" ]; then
|
elif [ "$( ls -A "$existing_dir" )" ]; then
|
||||||
die "--save-samples directory isn't empty, halting."
|
die "--save-samples directory isn't empty, halting."
|
||||||
fi
|
fi
|
||||||
touch "$OPT_SAVE_DATA/test" || die "Cannot write to $OPT_SAVE_DATA"
|
touch "$existing_dir/test" || die "Cannot write to $existing_dir"
|
||||||
rm "$OPT_SAVE_DATA/test" || die "Cannot rm $OPT_SAVE_DATA/test"
|
rm "$existing_dir/test" || die "Cannot rm $existing_dir/test"
|
||||||
data_dir="$OPT_SAVE_DATA"
|
data_dir="$existing_dir"
|
||||||
fi
|
fi
|
||||||
echo "$data_dir"
|
echo "$data_dir"
|
||||||
}
|
}
|
||||||
@@ -638,7 +638,7 @@ setup_data_dir () {
|
|||||||
get_var () {
|
get_var () {
|
||||||
local varname="$1"
|
local varname="$1"
|
||||||
local file="$2"
|
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.
|
# total and free space available to each volume.
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
format_lvs () { local PTFUNCNAME=format_lvs;
|
format_lvs () { local PTFUNCNAME=format_lvs;
|
||||||
local lvs_file="$1"
|
local file="$1"
|
||||||
local vgs_file="$2"
|
if [ -e "$file" ]; then
|
||||||
local lvs_errors="$3"
|
grep -v "open failed" "$file"
|
||||||
|
|
||||||
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
|
|
||||||
else
|
else
|
||||||
if [ -e "$lvs_file" ]; then
|
echo "Unable to collect information";
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -984,7 +961,9 @@ report_system_summary () { local PTFUNCNAME=report_system_summary;
|
|||||||
done
|
done
|
||||||
|
|
||||||
section "LVM_Volumes"
|
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
|
fi
|
||||||
|
|
||||||
section "RAID_Controller"
|
section "RAID_Controller"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
plan 49
|
plan 48
|
||||||
|
|
||||||
. "$LIB_DIR/alt_cmds.sh"
|
. "$LIB_DIR/alt_cmds.sh"
|
||||||
. "$LIB_DIR/log_warn_die.sh"
|
. "$LIB_DIR/log_warn_die.sh"
|
||||||
@@ -1267,21 +1267,16 @@ is \
|
|||||||
# parse_lvs
|
# parse_lvs
|
||||||
|
|
||||||
is \
|
is \
|
||||||
"$(format_lvs "" "" "")" \
|
"$(format_lvs "" "")" \
|
||||||
"Cannot execute 'lvs'" \
|
"Unable to collect information" \
|
||||||
"format_lvs has a meaningful error message if all goes wrong"
|
"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"
|
echo "Pretending to be an lvs dump" > "$TMPDIR/in"
|
||||||
is \
|
is \
|
||||||
"$(format_lvs "$TMPDIR/in" "" "")" \
|
"$(format_lvs "$TMPDIR/in" "")" \
|
||||||
"Pretending to be an lvs dump" \
|
"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
|
# report_system_summary
|
||||||
parse_options "$BIN_DIR/pt-summary"
|
parse_options "$BIN_DIR/pt-summary"
|
||||||
@@ -1514,6 +1509,8 @@ dentry-state | 78471 67588 45 0 0 0
|
|||||||
inode-nr | 70996 10387
|
inode-nr | 70996 10387
|
||||||
# LVM Volumes ################################################
|
# LVM Volumes ################################################
|
||||||
No volume groups found
|
No volume groups found
|
||||||
|
# LVM Volume Groups ##########################################
|
||||||
|
Unable to collect information
|
||||||
# RAID Controller ############################################
|
# RAID Controller ############################################
|
||||||
Controller | No RAID controller detected
|
Controller | No RAID controller detected
|
||||||
# Network Config #############################################
|
# Network Config #############################################
|
||||||
|
@@ -45,7 +45,9 @@ dentry-state | 9392 7451 45 0 0 0
|
|||||||
file-nr | 640 0 102187
|
file-nr | 640 0 102187
|
||||||
inode-nr | 5431 148
|
inode-nr | 5431 148
|
||||||
# LVM Volumes ################################################
|
# LVM Volumes ################################################
|
||||||
Cannot execute 'lvs'
|
Unable to collect information
|
||||||
|
# LVM Volume Groups ##########################################
|
||||||
|
Unable to collect information
|
||||||
# RAID Controller ############################################
|
# RAID Controller ############################################
|
||||||
Controller | No RAID controller detected
|
Controller | No RAID controller detected
|
||||||
# Network Config #############################################
|
# Network Config #############################################
|
||||||
|
@@ -42,7 +42,9 @@ dentry-state | 9175 7239 45 0 0 0
|
|||||||
file-nr | 640 0 102187
|
file-nr | 640 0 102187
|
||||||
inode-nr | 5259 148
|
inode-nr | 5259 148
|
||||||
# LVM Volumes ################################################
|
# LVM Volumes ################################################
|
||||||
Cannot execute 'lvs'
|
Unable to collect information
|
||||||
|
# LVM Volume Groups ##########################################
|
||||||
|
Unable to collect information
|
||||||
# RAID Controller ############################################
|
# RAID Controller ############################################
|
||||||
Controller | No RAID controller detected
|
Controller | No RAID controller detected
|
||||||
# Network Config #############################################
|
# Network Config #############################################
|
||||||
|
Reference in New Issue
Block a user