From: Kairui Song <kasong(a)tencent.com>
Make log saving the last step of kdump.sh, so it can catch more info, for
example, the output of post.d hooks will be covered by the log now.
Signed-off-by: Kairui Song <kasong(a)tencent.com>
---
dracut-kdump.sh | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b69bc98..b221eab 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -15,6 +15,8 @@ fi
KDUMP_PATH="/var/crash"
KDUMP_LOG_FILE="/run/initramfs/kexec-dmesg.log"
+KDUMP_LOG_DEST=""
+KDUMP_LOG_OP=""
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 7 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
@@ -119,6 +121,10 @@ save_log()
journalctl -ab >> $KDUMP_LOG_FILE
fi
chmod 600 $KDUMP_LOG_FILE
+
+ dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/"
+
+ eval "$KDUMP_LOG_OP"
}
# $1: dump path, must be a mount point
@@ -159,6 +165,9 @@ dump_fs()
save_opalcore_fs "$_dump_fs_path"
dinfo "saving vmcore"
+ KDUMP_LOG_DEST=$_dump_fs_path/
+ KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'"
+
$CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete"
_dump_exitcode=$?
if [ $_dump_exitcode -eq 0 ]; then
@@ -167,12 +176,6 @@ dump_fs()
dinfo "saving vmcore complete"
else
derror "saving vmcore failed, exitcode:$_dump_exitcode"
- fi
-
- dinfo "saving the $KDUMP_LOG_FILE to $_dump_fs_path/"
- save_log
- mv "$KDUMP_LOG_FILE" "$_dump_fs_path/"
- if [ $_dump_exitcode -ne 0 ]; then
return 1
fi
@@ -395,8 +398,12 @@ dump_ssh()
ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1
save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir"
"$_ssh_opt" "$2"
+
dinfo "saving vmcore"
+ KDUMP_LOG_DEST=$2:$_ssh_dir/
+ KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE'
'$_scp_address:$_ssh_dir/'"
+
save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2"
"$_scp_address"
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
@@ -421,12 +428,6 @@ dump_ssh()
derror "saving vmcore failed, exitcode:$_ret"
fi
- dinfo "saving the $KDUMP_LOG_FILE to $2:$_ssh_dir/"
- save_log
- if ! scp -q $_ssh_opt $KDUMP_LOG_FILE "$_scp_address:$_ssh_dir/"; then
- derror "saving log file failed, _exitcode:$_ret"
- fi
-
return $_ret
}
@@ -576,6 +577,8 @@ if ! do_kdump_post $DUMP_RETVAL; then
derror "kdump_post script exited with non-zero status!"
fi
+save_log
+
if [ $DUMP_RETVAL -ne 0 ]; then
exit 1
fi
--
2.34.1
Show replies by date