]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-debugpack.in
import quincy beta 17.1.0
[ceph.git] / ceph / src / ceph-debugpack.in
CommitLineData
7c673cae
FG
1#!/bin/sh
2
3# if we start up as ./init-ceph, assume everything else is in the
4# current directory too.
5if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then
6 BINDIR=.
7 LIBEXECDIR=.
8 ETCDIR=.
9else
10 BINDIR=@bindir@
11 LIBEXECDIR=@libexecdir@/ceph
12 ETCDIR=@sysconfdir@/ceph
13fi
14
15BINDBGDIR="/usr/lib/debug/usr/bin"
16
17usage_exit() {
18 echo "usage: $0 [-c ceph.conf] <filename.tar.gz>"
19 exit
20}
21
22wait_pid_exit() {
23 pid=$1
24
25 for i in $(seq 10); do
26 [ -e /proc/$pid ] || return
27 sleep 1
28 done
29 if [ -e /proc/$pid ]; then
30 echo Killing pid $pid
31 kill $pid
32 fi
33}
34
35. $LIBEXECDIR/ceph_common.sh
36
37dest_tar=''
38while [ $# -ge 1 ]; do
39case $1 in
40 --conf | -c)
41 [ -z "$2" ] && usage_exit
42 shift
43 conf=$1
44 ;;
45 *)
46 if [ -n "$dest_tar" ]; then
47 echo unrecognized option \'$1\'
48 usage_exit
49 fi
50 dest_tar=$1
51 ;;
52esac
53shift
54done
55
56[ "$dest_tar" = "" ] && usage_exit
57
58echo "$0: generating debugpack tarball..."
59
60if [ -e $dest_tar ]; then
61 echo "$0: dest $dest_tar already exists, aborting"
62 exit 1
63fi
64
65# get absolute path for dest_tar
66bins="ceph-mon ceph-mds ceph-osd radosgw"
67core_paths="/ $BINDIR $BINDBGDIR"
68[ "$conf" = "" ] && conf=$ETCDIR/ceph.conf
69log_path=`$CCONF -c $conf "log dir"`
70
71[ -z "$conf" ] && usage_exit
72
73# all configs
74files='/etc/ceph'
75
76# binaries
77for bin in bins; do
78 if [ -e "/usr/bin/$bin" ]; then
79 files="$files /usr/bin/$bin"
80 fi
81 if [ -e "/usr/lib/debug/usr/bin/$bin" ]; then
82 files="$files /usr/lib/debug/usr/bin/$bin"
83 fi
84done
85
86# logs (the non-rotated ones)
87for f in `find $path -maxdepth 1 -name 'core*'`; do
88 files="$files $f"
89done
90
91# copy cores (if exist)
92for path in $core_paths; do
93 if [ -d $path ]; then
94 for f in `find $path -maxdepth 1 -name 'core*'`; do
95 files="$files $f"
96 done
97 fi
98done
99
100# cluster state
101tmp_path=`mktemp -d /tmp/ceph-debugpack.XXXXXXXXXX`
102
103$BINDIR/ceph report > $tmp_path/ceph-report &
104wait_pid_exit $!
105
106files="$files $tmp_path"
107
108# now create a tarball
109tar cvfz $dest_tar $files
110rm -rf $tmp_path
111
112echo "$0: created debugpack tarball at $dest_tar"
113