kdump: Save vmcore-dmesg.txt before saving vmcore

Save vmcore-dmesg.txt before saving vmcore. For ssh targets, it assumes
that ssh is enabled. No scp logic as I don't have a local copy of
kernel log buffers and saving one will consume extra memory. We
can possibly enhance this logic to save kernel log buffers first locally
and then scp it (For setups which allow scp but disable ssh access).
(log is from Vivek Goyal <vgoyal@redhat.com>)

And add 1 section to describe it in kexec-kdump-howto.txt

v3->v4:
     Remove old description of dmesg in kexec-kdump-howto.txt, now
     add a new section to describe it, and note user kernel log
     buffers won't be available if dump target is raw device.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Baoquan He 2013-05-13 11:13:27 +08:00
parent c3635964c4
commit ca61e6a1bb
3 changed files with 52 additions and 0 deletions

View File

@ -7,6 +7,7 @@ set -x
KDUMP_PATH="/var/crash"
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -c --message-level 1 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
DEFAULT_ACTION="reboot -f"
DATEDIR=`date +%Y.%m.%d-%T`
HOST_IP='127.0.0.1'
@ -60,6 +61,9 @@ dump_fs()
mount -o remount,rw $_mp || return 1
fi
mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
$CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore || return 1
umount $_mp || return 1
return 0
@ -90,6 +94,9 @@ dump_to_rootfs()
mount -o remount,rw $NEWROOT/ || return 1
mkdir -p $NEWROOT/$KDUMP_PATH/$HOST_IP-$DATEDIR
save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$NEWROOT/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
$CORE_COLLECTOR /proc/vmcore $NEWROOT/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore || return 1
sync
}
@ -102,6 +109,8 @@ dump_ssh()
cat /var/lib/random-seed > /dev/urandom
ssh -q $_opt $2 mkdir -p $_dir || return 1
save_vmcore_dmesg_ssh ${DMESG_COLLECTOR} ${_dir} "${_opt}" $2
if [ "${CORE_COLLECTOR%% *}" = "scp" ]; then
scp -q $_opt /proc/vmcore "$2:$_dir/vmcore-incomplete" || return 1
ssh $_opt $2 "mv $_dir/vmcore-incomplete $_dir/vmcore" || return 1
@ -111,6 +120,40 @@ dump_ssh()
fi
}
save_vmcore_dmesg_fs() {
local _dmesg_collector=$1
local _path=$2
echo "Saving vmcore-dmesg.txt"
$_dmesg_collector /proc/vmcore > ${_path}/vmcore-dmesg-incomplete.txt
_exitcode=$?
if [ $_exitcode -eq 0 ]; then
mv ${_path}/vmcore-dmesg-incomplete.txt ${_path}/vmcore-dmesg.txt
echo "Saved vmcore-dmesg.txt"
else
echo "Saving vmcore-dmesg.txt failed"
fi
}
save_vmcore_dmesg_ssh() {
local _dmesg_collector=$1
local _path=$2
local _opts="$3"
local _location=$4
echo "Saving vmcore-dmesg.txt"
$_dmesg_collector /proc/vmcore | ssh $_opts $_location "dd of=$_path/vmcore-dmesg-incomplete.txt"
_exitcode=$?
if [ $_exitcode -eq 0 ]; then
ssh -q $_opts $_location mv $_path/vmcore-dmesg-incomplete.txt $_path/vmcore-dmesg.txt
echo "Saved vmcore-dmesg.txt"
else
echo "Saving vmcore-dmesg.txt failed"
fi
}
is_ssh_dump_target()
{
grep -q "^ssh[[:blank:]].*@" $conf_file

View File

@ -399,6 +399,7 @@ install() {
inst "/bin/sync" "/bin/sync"
inst "/bin/cut" "/bin/cut"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst_hook pre-pivot 9999 "$moddir/kdump.sh"
# Check for all the devices and if any device is iscsi, bring up iscsi

View File

@ -179,6 +179,14 @@ perform postmortem analysis:
and so on...
Saving vmcore-dmesg.txt
----------------------
Kernel log bufferes are one of the most important information available
in vmcore. Now before saving vmcore, kernel log bufferes are extracted
from /proc/vmcore and saved into a file vmcore-dmesg.txt. After
vmcore-dmesg.txt, vmcore is saved. Destination disk and directory for
vmcore-dmesg.txt is same as vmcore. Note that kernel log buffers will
not be available if dump target is raw device.
Dump Triggering methods: