ssh core_collector fix
1. add core_collector filter support to ssh dump 2. scp can be specified in kdump.conf 3. error out if no '-F' with makedumpfile 4. add proper explanation and examples to kdump.conf[.5] and kexec-kdump-howto.txt. v1->v2: add verify_core_collector function v2->v3: optimize the code, remove local variable for default core_collector Signed-off-by: Dave Young <dyoung@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
33d933f800
commit
2697669fa9
@ -4,7 +4,8 @@
|
||||
|
||||
set -x
|
||||
KDUMP_PATH="/var/crash"
|
||||
CORE_COLLECTOR="makedumpfile -c --message-level 1 -d 31"
|
||||
CORE_COLLECTOR=""
|
||||
DEFAULT_CORE_COLLECTOR="makedumpfile -c --message-level 1 -d 31"
|
||||
DEFAULT_ACTION="dump_rootfs"
|
||||
DATEDIR=`date +%d.%m.%y-%T`
|
||||
DUMP_INSTRUCTION=""
|
||||
@ -118,9 +119,23 @@ dump_nfs()
|
||||
|
||||
dump_ssh()
|
||||
{
|
||||
ssh -q -i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes $2 mkdir -p $KDUMP_PATH/$DATEDIR || return 1
|
||||
scp -q -i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes /proc/vmcore "$2:$KDUMP_PATH/$DATEDIR" || return 1
|
||||
return 0
|
||||
local _opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
||||
local _dir="$KDUMP_PATH/$DATEDIR"
|
||||
|
||||
ssh -q $_opt $2 mkdir -p $_dir || return 1
|
||||
|
||||
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
|
||||
else
|
||||
$CORE_COLLECTOR /proc/vmcore | ssh $_opt $2 "dd bs=512 of=$_dir/vmcore-incomplete" || return 1
|
||||
ssh $_opt $2 "mv $_dir/vmcore-incomplete $_dir/vmcore.flat" || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_ssh_dump_target()
|
||||
{
|
||||
grep -q "^net.*@" $conf_file
|
||||
}
|
||||
|
||||
read_kdump_conf()
|
||||
@ -188,6 +203,11 @@ read_kdump_conf()
|
||||
|
||||
read_kdump_conf
|
||||
|
||||
if [ -z "$CORE_COLLECTOR" ];then
|
||||
CORE_COLLECTOR=$DEFAULT_CORE_COLLECTOR
|
||||
is_ssh_dump_target && CORE_COLLECTOR="$CORE_COLLECTOR -F"
|
||||
fi
|
||||
|
||||
if [ -z "$DUMP_INSTRUCTION" ]; then
|
||||
add_dump_code "dump_rootfs"
|
||||
fi
|
||||
|
@ -44,7 +44,7 @@
|
||||
# options are not needed here, as the initrd will
|
||||
# automatically be populated with a config file
|
||||
# appropriate for the running kernel.
|
||||
# Default core_collector for raw dump is:
|
||||
# Default core_collector for raw/ssh dump is:
|
||||
# "makedumpfile -F -c --message-level 1 -d 31".
|
||||
# Default core_collector for other targets is:
|
||||
# "makedumpfile -c --message-level 1 -d 31".
|
||||
@ -91,6 +91,7 @@
|
||||
#sshkey /root/.ssh/kdump_id_rsa
|
||||
path /var/crash
|
||||
#core_collector makedumpfile -c --message-level 1 -d 31
|
||||
#core_collector scp
|
||||
#extra_bins /usr/bin/lftp
|
||||
#extra_modules gfs2
|
||||
#default shell
|
||||
|
36
kdump.conf.5
36
kdump.conf.5
@ -72,7 +72,7 @@ will automatically be populated with a config file appropriate
|
||||
for the running kernel.
|
||||
.PP
|
||||
Note 1: About default core collector:
|
||||
Default core_collector for raw dump is:
|
||||
Default core_collector for raw/ssh dump is:
|
||||
"makedumpfile -F -c --message-level 1 -d 31".
|
||||
Default core_collector for other targets is:
|
||||
"makedumpfile -c --message-level 1 -d 31".
|
||||
@ -141,10 +141,10 @@ Above will effectively be translated to:
|
||||
|
||||
makedumpfile -c --message-level 1 -d 31 /proc/vmcore <dest-path>/vmcore
|
||||
.PP
|
||||
For dump targets like raw, in general, core collector should expect
|
||||
For dump targets like raw and ssh, in general, core collector should expect
|
||||
one argument (source file) and should output the processed core on standard
|
||||
output. This standard output will be saved to destination using appropriate
|
||||
commands.
|
||||
output (There is one exception of "scp", discussed later). This standard
|
||||
output will be saved to destination using appropriate commands.
|
||||
|
||||
raw dumps examples:
|
||||
.TP
|
||||
@ -161,6 +161,34 @@ core_collector "makedumpfile -F -c --message-level 1 -d 31"
|
||||
Above will effectively be translated to.
|
||||
|
||||
makedumpfile -F -c --message-level 1 -d 31 | dd of=<target-device>
|
||||
.PP
|
||||
ssh dumps examples
|
||||
.TP
|
||||
ex5.
|
||||
core_collector "cat"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
|
||||
.TP
|
||||
ex6.
|
||||
core_collector "makedumpfile -F -c --message-level 1 -d 31"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
makedumpfile -F -c --message-level 1 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
|
||||
|
||||
There is one exception to standard output rule for ssh dumps. And that is
|
||||
scp. As scp can handle ssh destinations for file transfers, one can
|
||||
specify "scp" as core collector for ssh targets (no output on stdout).
|
||||
.TP
|
||||
ex7.
|
||||
core_collector "scp"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
scp /proc/vmcore <user@host>:path/vmcore
|
||||
|
||||
.PP
|
||||
examples for other options please see
|
||||
.I /etc/kdump.conf
|
||||
|
@ -467,10 +467,10 @@ Above will effectively be translated to:
|
||||
makedumpfile -c --message-level 1 -d 31 /proc/vmcore <dest-path>/vmcore
|
||||
|
||||
|
||||
For dump targets like raw, in general, core collector should expect
|
||||
For dump targets like raw and ssh, in general, core collector should expect
|
||||
one argument (source file) and should output the processed core on standard
|
||||
output. This standard output will be saved to destination using appropriate
|
||||
commands.
|
||||
output (There is one exception of "scp", discussed later). This standard
|
||||
output will be saved to destination using appropriate commands.
|
||||
|
||||
raw dumps core_collector examples:
|
||||
---------
|
||||
@ -490,6 +490,36 @@ Above will effectively be translated to.
|
||||
|
||||
makedumpfile -F -c --message-level 1 -d 31 | dd of=<target-device>
|
||||
|
||||
ssh dumps core_collector examples:
|
||||
---------
|
||||
ex5.
|
||||
---
|
||||
core_collector "cat"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
cat /proc/vmcore | ssh <options> <remote-location> "dd of=path/vmcore"
|
||||
|
||||
ex6.
|
||||
---
|
||||
core_collector "makedumpfile -F -c --message-level 1 -d 31"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
makedumpfile -F -c --message-level 1 -d 31 | ssh <options> <remote-location> "dd of=path/vmcore"
|
||||
|
||||
There is one exception to standard output rule for ssh dumps. And that is
|
||||
scp. As scp can handle ssh destinations for file transfers, one can
|
||||
specify "scp" as core collector for ssh targets (no output on stdout).
|
||||
|
||||
ex7.
|
||||
----
|
||||
core_collector "scp"
|
||||
|
||||
Above will effectively be translated to.
|
||||
|
||||
scp /proc/vmcore <user@host>:path/vmcore
|
||||
|
||||
About default core collector
|
||||
----------------------------
|
||||
Default core_collector for ssh/raw dump is:
|
||||
|
22
mkdumprd
22
mkdumprd
@ -91,6 +91,24 @@ check_remote() {
|
||||
return
|
||||
}
|
||||
|
||||
is_ssh_dump_target()
|
||||
{
|
||||
grep -q "^net.*@" $conf_file
|
||||
}
|
||||
|
||||
# $1: core_collector config value
|
||||
verify_core_collector() {
|
||||
if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then
|
||||
echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
|
||||
fi
|
||||
if is_ssh_dump_target && [ "${1%% *}" = "makedumpfile" ]; then
|
||||
! strstr "$1" "-F" && {
|
||||
echo "The specified dump target needs makedumpfile \"-F\" option."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
add_mount() {
|
||||
local _dev=$(to_dev_name "$1")
|
||||
local _mnt=$(to_mount "$1")
|
||||
@ -150,9 +168,7 @@ do
|
||||
fi
|
||||
;;
|
||||
core_collector)
|
||||
if grep -q "^raw" $conf_file && [ "${config_val%% *}" != "makedumpfile" ]; then
|
||||
echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
|
||||
fi
|
||||
verify_core_collector "$config_val"
|
||||
add_dracut_arg "-I" "${config_val%% *}"
|
||||
;;
|
||||
extra_bins)
|
||||
|
Loading…
Reference in New Issue
Block a user