summaryrefslogtreecommitdiffstats
path: root/src/multi-dump.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/multi-dump.sh
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/multi-dump.sh')
-rwxr-xr-xsrc/multi-dump.sh97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/multi-dump.sh b/src/multi-dump.sh
new file mode 100755
index 00000000..011f9539
--- /dev/null
+++ b/src/multi-dump.sh
@@ -0,0 +1,97 @@
+#!/usr/bin/env bash
+
+#
+# multi-dump.sh
+#
+# Dumps interesting information about the Ceph cluster at a series of epochs.
+#
+
+### Functions
+usage() {
+ cat <<EOF
+multi-dump.sh: dumps out ceph maps
+
+-D Enable diff-mode
+-e <start-epoch> What epoch to end with.
+-h This help message
+-s <start-epoch> What epoch to start with. Defaults to 1.
+-t <map-type> What type of map to dump. Defaults to osdmap.
+ Valid map types are: osdmap,
+EOF
+}
+
+cleanup() {
+ [ -n ${TEMPDIR} ] && rm -rf "${TEMPDIR}"
+}
+
+die() {
+ echo $@
+ exit 1
+}
+
+dump_osdmap() {
+ for v in `seq $START_EPOCH $END_EPOCH`; do
+ ./ceph osd getmap $v -o $TEMPDIR/$v >> $TEMPDIR/cephtool-out \
+ || die "cephtool failed to dump epoch $v"
+ done
+ if [ $DIFFMODE -eq 1 ]; then
+ for v in `seq $START_EPOCH $END_EPOCH`; do
+ ./osdmaptool --print $TEMPDIR/$v > $TEMPDIR/$v.out
+ done
+ cat $TEMPDIR/$START_EPOCH.out
+ E=$((END_EPOCH-1))
+ for v in `seq $START_EPOCH $E`; do
+ S=$((v+1))
+ echo "************** $S **************"
+ diff $TEMPDIR/$v.out $TEMPDIR/$S.out
+ done
+ else
+ for v in `seq $START_EPOCH $END_EPOCH`; do
+ echo "************** $v **************"
+ ./osdmaptool --print $TEMPDIR/$v \
+ || die "osdmaptool failed to print epoch $v"
+ done
+ fi
+}
+
+### Setup
+trap cleanup INT TERM EXIT
+TEMPDIR=`mktemp -d`
+MYDIR=`dirname $0`
+MYDIR=`readlink -f $MYDIR`
+MAP_TYPE=osdmap
+cd $MYDIR
+
+### Parse arguments
+DIFFMODE=0
+START_EPOCH=1
+END_EPOCH=0
+
+while getopts "De:hs:t:" flag; do
+case $flag in
+ D) DIFFMODE=1;;
+
+ e) END_EPOCH=$OPTARG;;
+
+ h) usage
+ exit 0
+ ;;
+
+ s) START_EPOCH=$OPTARG;;
+
+ t) MAP_TYPE=$OPTARG;;
+
+ *) usage
+ exit 1;;
+esac
+done
+[ $END_EPOCH -eq 0 ] && die "You must supply an end epoch with -e"
+
+### Dump maps
+case $MAP_TYPE in
+ "osdmap") dump_osdmap;;
+
+ *) die "sorry, don't know how to handle MAP_TYPE '$MAP_TYPE'"
+esac
+
+exit 0