Suppress ls output when it fails. Handle missing diskstats and vmstat. Shorten synopsis.

This commit is contained in:
Daniel Nichter
2012-07-23 16:39:49 -06:00
parent 8742381029
commit 4f0661c102

View File

@@ -59,7 +59,11 @@ rm_tmpdir() {
# ###########################################################################
TOOL="pt-sift"
if [ -d "/var/lib/pt-stalk" ]; then
BASEDIR="/var/lib/pt-stalk"
else
BASEDIR="$PWD"
fi
PREFIX=""
# ###########################################################################
@@ -150,7 +154,7 @@ main() {
# there is no PREFIX yet. NOTE: we rely on the "-df" files here.
(
cd "$BASEDIR"
ls *-df | cut -d- -f1 | sort > "$PT_TMPDIR/pt-sift.prefixes"
ls *-df 2>/dev/null | cut -d- -f1 | sort > "$PT_TMPDIR/pt-sift.prefixes"
)
if [ ! -s "$PT_TMPDIR/pt-sift.prefixes" ]; then
echo "Error: There are no pt-stalk files in $BASEDIR" >&2
@@ -206,6 +210,7 @@ main() {
# Format a brief report: busiest device's disk stats, CPU stats
DEFAULT)
echo "--diskstats--"
if [ -f "${BASEDIR}/${PREFIX}-diskstats" ]; then
$PR_diskstats --group-by disk "${BASEDIR}/${PREFIX}-diskstats" \
| awk '
@@ -256,8 +261,12 @@ main() {
}
}"
echo
else
echo " No diskstats file exists"
fi
echo "--vmstat--"
if [ -f "${BASEDIR}/${PREFIX}-vmstat" ]; then
tail -n 3 "${BASEDIR}/${PREFIX}-vmstat-overall" | $PR_align
# Figure out which column is 'wa' and print this, similar to the
@@ -280,6 +289,9 @@ main() {
}
}" "${BASEDIR}/${PREFIX}-vmstat"
echo
else
echo " No vmstat file exists"
fi
echo "--innodb--"
awk '
@@ -594,13 +606,12 @@ pt-sift - Browses files created by pt-stalk.
Usage: pt-sift FILE|PREFIX|DIRECTORY
pt-sift browses files created by L<pt-stalk>. If no options are given,
the tool browses all pt-stalk files in the current working directory.
Specify a DIRECTORY to browse all files in that directory. Specify
a FILE to browse all files with the same prefix in that file's directory.
Specify a PREFIX to browse all files in the current working directory
with that prefix. Prefixes are timestamps like C<2012_07_23_14_27_11>.
The tool prompts for a prefix if more than is found, else the only available
prefix is used by default.
the tool browses all pt-stalk files in C</var/lib/pt-stalk> if that directory
exists, else the current working directory is used. If a FILE is given,
the tool browses files with the same prefix in the given file's directory.
If a PREFIX is given, the tool browses files in C</var/lib/pt-stalk>
(or the current working directory) with the same prefix. If a DIRECTORY
is given, the tool browses all pt-stalk files in it.
=head1 RISKS