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"
|
FINAL_ACTION="reboot -f"
|
||||||
DUMP_RETVAL=0
|
DUMP_RETVAL=0
|
||||||
conf_file="/etc/kdump.conf"
|
conf_file="/etc/kdump.conf"
|
||||||
|
KDUMP_PRE=""
|
||||||
|
KDUMP_POST=""
|
||||||
|
|
||||||
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
export PATH=$PATH:$KDUMP_SCRIPT_DIR
|
||||||
|
|
||||||
@ -32,6 +34,20 @@ do_default_action()
|
|||||||
$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()
|
add_dump_code()
|
||||||
{
|
{
|
||||||
DUMP_INSTRUCTION=$1
|
DUMP_INSTRUCTION=$1
|
||||||
@ -164,6 +180,12 @@ read_kdump_conf()
|
|||||||
SSH_KEY_LOCATION=$config_val
|
SSH_KEY_LOCATION=$config_val
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
kdump_pre)
|
||||||
|
KDUMP_PRE="$config_val"
|
||||||
|
;;
|
||||||
|
kdump_post)
|
||||||
|
KDUMP_POST="$config_val"
|
||||||
|
;;
|
||||||
default)
|
default)
|
||||||
case $config_val in
|
case $config_val in
|
||||||
shell)
|
shell)
|
||||||
@ -218,8 +240,20 @@ if [ -z "$DUMP_INSTRUCTION" ]; then
|
|||||||
add_dump_code "dump_rootfs"
|
add_dump_code "dump_rootfs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
do_kdump_pre
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "kdump_pre script exited with non-zero status!"
|
||||||
|
$FINAL_ACTION
|
||||||
|
fi
|
||||||
|
|
||||||
$DUMP_INSTRUCTION
|
$DUMP_INSTRUCTION
|
||||||
DUMP_RETVAL=$?
|
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
|
if [ $DUMP_RETVAL -ne 0 ]; then
|
||||||
do_default_action
|
do_default_action
|
||||||
fi
|
fi
|
||||||
|
@ -156,6 +156,9 @@ kdump_install_conf() {
|
|||||||
net)
|
net)
|
||||||
kdump_install_net "$config_val"
|
kdump_install_net "$config_val"
|
||||||
;;
|
;;
|
||||||
|
kdump_pre|kdump_post)
|
||||||
|
dracut_install $config_val
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done < /etc/kdump.conf
|
done < /etc/kdump.conf
|
||||||
|
|
||||||
|
22
kdump.conf
22
kdump.conf
@ -51,10 +51,28 @@
|
|||||||
# For core_collector format details please refer to
|
# For core_collector format details please refer to
|
||||||
# kexec-kdump-howto.txt or kdump.conf manpage.
|
# 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>
|
# extra_bins <binaries | shell scripts>
|
||||||
# - This directive allows you to specify additional
|
# - This directive allows you to specify additional
|
||||||
# binaries or shell scripts you'd like to include in
|
# 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)>
|
# extra_modules <module(s)>
|
||||||
# - This directive allows you to specify extra kernel
|
# - This directive allows you to specify extra kernel
|
||||||
@ -92,6 +110,8 @@
|
|||||||
path /var/crash
|
path /var/crash
|
||||||
#core_collector makedumpfile -c --message-level 1 -d 31
|
#core_collector makedumpfile -c --message-level 1 -d 31
|
||||||
#core_collector scp
|
#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_bins /usr/bin/lftp
|
||||||
#extra_modules gfs2
|
#extra_modules gfs2
|
||||||
#default shell
|
#default shell
|
||||||
|
32
kdump.conf.5
32
kdump.conf.5
@ -89,11 +89,41 @@ ie. "makedumpfile -R vmcore < vmcore.flat"
|
|||||||
|
|
||||||
.RE
|
.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>
|
.B extra_bins <binaries | shell scripts>
|
||||||
.RS
|
.RS
|
||||||
This directive allows you to specify additional
|
This directive allows you to specify additional
|
||||||
binaries or shell scripts you'd like to include in
|
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
|
.RE
|
||||||
|
|
||||||
.B extra_modules <module(s)>
|
.B extra_modules <module(s)>
|
||||||
|
7
kdumpctl
7
kdumpctl
@ -101,8 +101,11 @@ function check_config()
|
|||||||
image_time=0
|
image_time=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
|
||||||
EXTRA_BINS=`grep ^extra_bins $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"
|
files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS"
|
||||||
|
|
||||||
check_exist "$files" && check_executable "$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
|
that the path option is ingnored if your kdump configuration results in the
|
||||||
core being saved from the initscripts in the root filesystem.
|
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
|
Extra Binaries
|
||||||
|
|
||||||
If you have specific binaries or scripts you want to have made available
|
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
|
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.
|
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
|
Extra Modules
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user