2010-10-05 23:16:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if we start up as ./init-ceph, assume everything else is in the
|
|
|
|
# current directory too.
|
|
|
|
if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then
|
|
|
|
BINDIR=.
|
|
|
|
LIBDIR=.
|
|
|
|
ETCDIR=.
|
|
|
|
else
|
|
|
|
BINDIR=@bindir@
|
|
|
|
LIBDIR=@libdir@/ceph
|
|
|
|
# i hate autoconf:
|
|
|
|
if [ "@sysconfdir@" = "/usr/etc" ]; then
|
|
|
|
ETCDIR=/etc/ceph
|
|
|
|
else
|
|
|
|
ETCDIR=@sysconfdir@/ceph
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
BINDBGDIR="/usr/lib/debug/usr/bin"
|
|
|
|
|
|
|
|
usage_exit() {
|
2010-10-07 16:31:13 +00:00
|
|
|
echo "usage: $0 [-c ceph.conf] <filename.tar.gz>"
|
2010-10-05 23:16:18 +00:00
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2010-10-07 03:04:38 +00:00
|
|
|
wait_pid_exit() {
|
|
|
|
pid=$1
|
|
|
|
|
|
|
|
for i in {1..10}; do
|
|
|
|
[ -e /proc/$pid ] || return
|
|
|
|
sleep 1
|
|
|
|
done
|
2010-10-07 16:47:34 +00:00
|
|
|
if [ -e /proc/$pid ]; then
|
|
|
|
echo Killing pid $pid
|
|
|
|
kill $pid
|
|
|
|
fi
|
2010-10-07 03:04:38 +00:00
|
|
|
}
|
|
|
|
|
2010-10-05 23:16:18 +00:00
|
|
|
|
|
|
|
. $LIBDIR/ceph_common.sh
|
|
|
|
|
|
|
|
dest_tar=""
|
|
|
|
|
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
case $1 in
|
|
|
|
--conf | -c)
|
|
|
|
[ -z "$2" ] && usage_exit
|
|
|
|
shift
|
|
|
|
conf=$1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ "$dest_tar" != "" ]; then
|
|
|
|
echo unrecognized option \'$1\'
|
|
|
|
usage_exit
|
|
|
|
fi
|
|
|
|
dest_tar=$1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2010-10-07 16:47:34 +00:00
|
|
|
[ "$dest_tar" = "" ] && usage_exit
|
2010-10-05 23:16:18 +00:00
|
|
|
|
|
|
|
# get absolute path for dest_tar
|
2010-10-07 16:47:34 +00:00
|
|
|
[ `echo $dest_tar | cut -c 1` != "/" ] && dest_tar="`pwd`/$dest_tar"
|
2010-10-05 23:16:18 +00:00
|
|
|
|
|
|
|
bins="cmon cmds cosd"
|
|
|
|
core_paths="/ $BINDIR $BINDBGDIR"
|
2010-10-07 16:47:34 +00:00
|
|
|
[ "$conf" = "" ] && conf=$ETCDIR/ceph.conf
|
2010-10-05 23:16:18 +00:00
|
|
|
log_path=`$CCONF -c $conf "log dir"`
|
|
|
|
|
|
|
|
[ -z "$conf" ] && usage_exit
|
|
|
|
|
|
|
|
|
|
|
|
tmp_path=`mktemp -d /tmp/cdebugpack.XXXXXXXXXX`
|
|
|
|
tmp_path_bin=$tmp_path/bin
|
|
|
|
tmp_path_bin_dbg=$tmp_path/bin.dbg
|
|
|
|
tmp_path_log=$tmp_path/out
|
|
|
|
tmp_path_core=$tmp_path/core
|
2010-10-07 03:04:38 +00:00
|
|
|
tmp_path_etc=$tmp_path/etc
|
2010-10-05 23:16:18 +00:00
|
|
|
|
|
|
|
echo tmp_path=$tmp_path
|
|
|
|
|
|
|
|
mkdir -p $tmp_path_bin
|
|
|
|
mkdir -p $tmp_path_bin_dbg
|
|
|
|
mkdir -p $tmp_path_log
|
|
|
|
mkdir -p $tmp_path_core
|
2010-10-07 03:04:38 +00:00
|
|
|
mkdir -p $tmp_path_etc
|
2010-10-05 23:16:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
#copy the binaries
|
|
|
|
|
|
|
|
for name in $bins; do
|
|
|
|
[ -e $BINDIR/$name ] && cp $BINDIR/$name $tmp_path_bin
|
|
|
|
[ -e $BINDBGDIR/$name ] && cp $BINDBGDIR/$name $tmp_path_bin_dbg
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# copy the logs
|
|
|
|
cp -rp $log_path/* $tmp_path_log
|
|
|
|
|
|
|
|
# copy cores (if exist)
|
|
|
|
|
|
|
|
for path in $core_paths; do
|
|
|
|
files="`find $path -maxdepth 1 -name 'core*'`"
|
|
|
|
if [ "$files" != "" ]; then
|
|
|
|
for core_file in `ls $path/core*`; do
|
|
|
|
tmp_core=`mktemp $tmp_path_core/core.XXXX`
|
|
|
|
cp $core_file $tmp_core
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-10-07 03:04:38 +00:00
|
|
|
# copy config
|
|
|
|
cp $conf $tmp_path_etc
|
|
|
|
|
|
|
|
# other output
|
|
|
|
$BINDIR/ceph -s > $tmp_path_log/ceph-s &
|
|
|
|
wait_pid_exit $!
|
|
|
|
$BINDIR/ceph osd dump -o $tmp_path_log/ceph-osd-dump &
|
|
|
|
wait_pid_exit $!
|
|
|
|
$BINDIR/ceph mds dump -o $tmp_path_log/ceph-mds-dump &
|
|
|
|
wait_pid_exit $!
|
2010-10-07 03:30:11 +00:00
|
|
|
$BINDIR/ceph pg dump -o $tmp_path_log/ceph-pg-dump &
|
|
|
|
wait_pid_exit $!
|
2010-10-07 03:04:38 +00:00
|
|
|
|
2010-10-05 23:16:18 +00:00
|
|
|
|
|
|
|
# now create a tarball
|
2010-10-07 16:31:31 +00:00
|
|
|
tmp_path_dir=`echo $tmp_path | cut -d / -f 3`
|
|
|
|
tar cvfz $dest_tar -C /tmp $tmp_path_dir
|
2010-10-05 23:16:18 +00:00
|
|
|
rm -fR $tmp_path
|
|
|
|
|