]>
sourceware.org Git - lvm2.git/blob - scripts/lvm_dump.sh
2 # we use some bash-isms (getopts?)
4 # lvm_dump: This script is used to collect pertinent information for
5 # the debugging of lvm issues.
7 # following external commands are used throughout the script
8 # which, echo and test are internal in bash at least
13 TAIL
=tail # we need -n
23 # user may override lvm and dmsetup location by setting LVM_BINARY
24 # and DMSETUP_BINARY respectively
26 DMSETUP
=${DMSETUP_BINARY-dmsetup}
34 # which should error out if the binary is not executable, although i
35 # am not sure we can rely on this
36 which $LVM >& /dev
/null || die
2 "Fatal: could not find lvm binary '$LVM'"
37 test -x `which $LVM` || die
2 "Fatal: lvm binary '$LVM' not executable"
38 which $DMSETUP >& /dev
/null || die
2 "Fatal: could not find dmsetup binary '$DMSETUP'"
39 test -x `which $DMSETUP` || die
2 "Fatal: dmsetup binary '$DMSETUP' not executable"
43 echo " -h print this message"
44 echo " -a advanced collection - warning: if lvm is already hung,"
45 echo " then this script may hang as well if -a is used"
46 echo " -m gather LVM metadata from the PVs"
47 echo " -d <directory> dump into a directory instead of tarball"
48 echo " -c if running clvmd, gather cluster data as well"
57 while getopts :acd
:hm opt
; do
65 :) echo "$0: $OPTARG requires a value:"; usage
;;
66 \?) echo "$0: unknown option $OPTARG"; usage
;;
71 NOW
=`$DATE -u +%G%m%d%k%M%S | /usr/bin/tr -d ' '`
72 if test -n "$userdir"; then
75 dirbase
="lvmdump-$HOSTNAME-$NOW"
79 test -e $dir && die
3 "Fatal: $dir already exists"
80 $MKDIR -p $dir || die
4 "Fatal: could not create $dir"
82 log
="$dir/lvmdump.log"
95 myecho
"Creating dump directory: $dir"
98 if (( $advanced )); then
99 myecho
"Gathering LVM volume info..."
102 log
"$LVM vgscan -vvvv > $dir/vgscan 2>&1"
105 log
"$LVM pvscan -v >> $dir/pvscan 2>> $log"
108 log
"$LVM lvs -a -o +devices >> $dir/lvs 2>> $log"
111 log
"$LVM pvs -a -v > $dir/pvs 2>> $log"
114 log
"$LVM vgs -v > $dir/vgs 2>> $log"
117 if (( $clustered )); then
118 myecho
"Gathering cluster info..."
121 for i
in nodes status services
; do
122 cap_i
=$
(echo $i|
tr a-z A-Z
)
123 printf "$cap_i:\n----------------------------------\n"
124 log
"cman_tool $i 2>> $log"
129 echo "----------------------------------"
130 if [ -f /proc
/cluster
/dlm_locks
]
132 echo clvmd
> /proc
/cluster
/dlm_locks
133 cat /proc
/cluster
/dlm_locks
136 cat /proc
/cluster
/dlm_dir
139 cat /proc
/cluster
/dlm_debug
142 if [ -f /debug
/dlm
/clvmd
]
147 cat /debug
/dlm
/clvmd_waiters
150 cat /debug
/dlm
/clvmd_master
152 } > $dir/cluster_info
155 myecho
"Gathering LVM & device-mapper version info..."
156 echo "LVM VERSION:" > $dir/versions
157 $LVM lvs
--version >> $dir/versions
2>> $log
158 echo "DEVICE MAPPER VERSION:" >> $dir/versions
159 $DMSETUP --version >> $dir/versions
2>> $log
160 echo "KERNEL VERSION:" >> $dir/versions
161 $UNAME -a >> $dir/versions
2>> $log
162 echo "DM TARGETS VERSIONS:" >> $dir/versions
163 $DMSETUP targets
>> $dir/versions
2>> $log
165 myecho
"Gathering dmsetup info..."
166 log
"$DMSETUP info -c > $dir/dmsetup_info 2>> $log"
167 log
"$DMSETUP table > $dir/dmsetup_table 2>> $log"
168 log
"$DMSETUP status > $dir/dmsetup_status 2>> $log"
170 myecho
"Gathering process info..."
171 log
"$PS alx > $dir/ps_info 2>> $log"
173 myecho
"Gathering console messages..."
174 log
"$TAIL -n 75 /var/log/messages > $dir/messages 2>> $log"
176 myecho
"Gathering /etc/lvm info..."
177 log
"$CP -a /etc/lvm $dir/lvm 2>> $log"
179 myecho
"Gathering /dev listing..."
180 log
"$LS -laR /dev > $dir/dev_listing 2>> $log"
182 myecho
"Gathering /sys/block listing..."
183 log
"$LS -laR /sys/block > $dir/sysblock_listing"
185 if (( $metadata )); then
186 myecho
"Gathering LVM metadata from Physical Volumes..."
188 log
"$MKDIR -p $dir/metadata"
190 pvs
="$($LVM pvs --separator , --noheadings --units s --nosuffix -o \
191 name,pe_start 2>> $log | $SED -e 's/^ *//')"
194 test -z "$line" && continue
195 pv
="$(echo $line | $CUT -d, -f1)"
196 pe_start
="$(echo $line | $CUT -d, -f2)"
197 name
="$($BASENAME $pv)"
199 log
"$DD if=$pv of=$dir/metadata/$name bs=512 count=$pe_start 2>> $log"
203 if test -z "$userdir"; then
204 lvm_dump
="$dirbase.tgz"
205 myecho
"Creating report tarball in $HOME/$lvm_dump..."
207 $TAR czf
$lvm_dump $dirbase 2>/dev
/null
211 if test "$UID" != "0" && test "$EUID" != "0"; then
213 myecho
"WARNING! Running as non-privileged user, dump is likely incomplete!"
This page took 0.708127 seconds and 6 git commands to generate.