Add kdump_post and kdump_pre support
Original patch is from Amerigo, but it has changed a lot: remove multi dump refreshed with latest git for the dump instruction function restructure fixed the behavior of do_kdump_pre, if kdump_pre fails it will reboot update the docs check the existance and executable of kdump_pre/post files, also check the timestamp of them for rebuilding. refresh patch, Address comments from vivek: s/hush/bash in docs fix the copy-paste error in kdump post error message s/reboot\/halt/reboot in kexec-kdump-howto.txt Signed-off-by: Dave Young <dyoung@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
836815ff67
commit
4e4a173698
@ -15,6 +15,8 @@ DD_BLKSIZE=512
|
||||
FINAL_ACTION="reboot -f"
|
||||
DUMP_RETVAL=0
|
||||
conf_file="/etc/kdump.conf"
|
||||
KDUMP_PRE=""
|
||||
KDUMP_POST=""
|
||||
|
||||
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
||||
|
||||
@ -32,6 +34,20 @@ do_default_action()
|
||||
$DEFAULT_ACTION
|
||||
}
|
||||
|
||||
do_kdump_pre()
|
||||
{
|
||||
if [ -n "$KDUMP_PRE" ]; then
|
||||
"$KDUMP_PRE"
|
||||
fi
|
||||
}
|
||||
|
||||
do_kdump_post()
|
||||
{
|
||||
if [ -n "$KDUMP_POST" ]; then
|
||||
"$KDUMP_POST" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
add_dump_code()
|
||||
{
|
||||
DUMP_INSTRUCTION=$1
|
||||
@ -164,6 +180,12 @@ read_kdump_conf()
|
||||
SSH_KEY_LOCATION=$config_val
|
||||
fi
|
||||
;;
|
||||
kdump_pre)
|
||||
KDUMP_PRE="$config_val"
|
||||
;;
|
||||
kdump_post)
|
||||
KDUMP_POST="$config_val"
|
||||
;;
|
||||
default)
|
||||
case $config_val in
|
||||
shell)
|
||||
@ -218,8 +240,20 @@ if [ -z "$DUMP_INSTRUCTION" ]; then
|
||||
add_dump_code "dump_rootfs"
|
||||
fi
|
||||
|
||||
do_kdump_pre
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "kdump_pre script exited with non-zero status!"
|
||||
$FINAL_ACTION
|
||||
fi
|
||||
|
||||
$DUMP_INSTRUCTION
|
||||
DUMP_RETVAL=$?
|
||||
|
||||
do_kdump_post $DUMP_RETVAL
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "kdump_post script exited with non-zero status!"
|
||||
fi
|
||||
|
||||
if [ $DUMP_RETVAL -ne 0 ]; then
|
||||
do_default_action
|
||||
fi
|
||||
|
@ -156,6 +156,9 @@ kdump_install_conf() {
|
||||
net)
|
||||
kdump_install_net "$config_val"
|
||||
;;
|
||||
kdump_pre|kdump_post)
|
||||
dracut_install $config_val
|
||||
;;
|
||||
esac
|
||||
done < /etc/kdump.conf
|
||||
|
||||
|
22
kdump.conf
22
kdump.conf
@ -51,10 +51,28 @@
|
||||
# For core_collector format details please refer to
|
||||
# kexec-kdump-howto.txt or kdump.conf manpage.
|
||||
#
|
||||
# kdump_post <binary | script>
|
||||
# - This directive allows you to run a specified
|
||||
# executable just after the memory dump process
|
||||
# terminates. The exit status from the dump process
|
||||
# is fed to the kdump_post executable, which can be
|
||||
# used to trigger different actions for success or
|
||||
# failure.
|
||||
#
|
||||
# kdump_pre <binary | script>
|
||||
# - works just like the kdump_post directive, but instead
|
||||
# of running after the dump process, runs immediately
|
||||
# before. Exit status of this binary is interpreted
|
||||
# as follows:
|
||||
# 0 - continue with dump process as usual
|
||||
# non 0 - reboot the system
|
||||
#
|
||||
# extra_bins <binaries | shell scripts>
|
||||
# - This directive allows you to specify additional
|
||||
# binaries or shell scripts you'd like to include in
|
||||
# your kdump initrd.
|
||||
# your kdump initrd. Generally only useful in
|
||||
# conjunction with a kdump_post binary or script that
|
||||
# relies on other binaries or scripts.
|
||||
#
|
||||
# extra_modules <module(s)>
|
||||
# - This directive allows you to specify extra kernel
|
||||
@ -92,6 +110,8 @@
|
||||
path /var/crash
|
||||
#core_collector makedumpfile -c --message-level 1 -d 31
|
||||
#core_collector scp
|
||||
#kdump_post /var/crash/scripts/kdump-post.sh
|
||||
#kdump_pre /var/crash/scripts/kdump-pre.sh
|
||||
#extra_bins /usr/bin/lftp
|
||||
#extra_modules gfs2
|
||||
#default shell
|
||||
|
32
kdump.conf.5
32
kdump.conf.5
@ -89,11 +89,41 @@ ie. "makedumpfile -R vmcore < vmcore.flat"
|
||||
|
||||
.RE
|
||||
|
||||
.B kdump_post <binary | script>
|
||||
.RS
|
||||
This directive allows you to run a specified
|
||||
executable just after the memory dump process
|
||||
terminates. The exit status from the dump process
|
||||
is fed to the kdump_post executable, which can be
|
||||
used to trigger different actions for success or
|
||||
failure.
|
||||
.PP
|
||||
Note that scripts written for use with this
|
||||
directive must use the /bin/bash interpreter
|
||||
.RE
|
||||
|
||||
.B kdump_pre <binary | script>
|
||||
.RS
|
||||
Works just like the kdump_post directive, but instead
|
||||
of running after the dump process, runs immediately
|
||||
before. Exit status of this binary is interpreted
|
||||
as follows:
|
||||
.PP
|
||||
0 - continue with dump process as usual
|
||||
.PP
|
||||
non 0 - reboot the system
|
||||
.PP
|
||||
Note that scripts written for this directive must use
|
||||
the /bin/bash interpreter
|
||||
.RE
|
||||
|
||||
.B extra_bins <binaries | shell scripts>
|
||||
.RS
|
||||
This directive allows you to specify additional
|
||||
binaries or shell scripts you'd like to include in
|
||||
your kdump initrd.
|
||||
your kdump initrd. Generally only useful in
|
||||
conjunction with a kdump_post binary or script that
|
||||
relies on other binaries or scripts.
|
||||
.RE
|
||||
|
||||
.B extra_modules <module(s)>
|
||||
|
7
kdumpctl
7
kdumpctl
@ -101,8 +101,11 @@ function check_config()
|
||||
image_time=0
|
||||
fi
|
||||
|
||||
|
||||
EXTRA_BINS=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
|
||||
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
||||
CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
||||
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
|
||||
CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
|
||||
EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
|
||||
files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS"
|
||||
|
||||
check_exist "$files" && check_executable "$EXTRA_BINS"
|
||||
|
@ -403,11 +403,27 @@ example, 'path /data/coredumps' would lead to vmcore files being written to
|
||||
that the path option is ingnored if your kdump configuration results in the
|
||||
core being saved from the initscripts in the root filesystem.
|
||||
|
||||
Kdump Post-Capture Executable
|
||||
|
||||
It is possible to specify a custom script or binary you wish to run following
|
||||
an attempt to capture a vmcore. The executable is passed an exit code from
|
||||
the capture process, which can be used to trigger different actions from
|
||||
within your post-capture executable.
|
||||
|
||||
Kdump Pre-Capture Executable
|
||||
|
||||
It is possible to specify a custom script or binary you wish to run before
|
||||
capturing a vmcore. Exit status of this binary is interpreted:
|
||||
0 - continue with dump process as usual
|
||||
non 0 - reboot the system
|
||||
|
||||
Extra Binaries
|
||||
|
||||
If you have specific binaries or scripts you want to have made available
|
||||
within your kdump initrd, you can specify them by their full path, and they
|
||||
will be included in your kdump initrd, along with all dependent libraries.
|
||||
This may be particularly useful for those running post-capture scripts that
|
||||
rely on other binaries.
|
||||
|
||||
Extra Modules
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user