change the dump dir format to be more readable

Resolves: bz880551

Currently on fedora directory name of kdump is like 14.11.12-03:40:30.
It's not as readable as RHEL6. The old format of dir is host_ip-date-time.
This patch changes it back like ole one as below.
192.168.122.234-2012-10-31-05:17:20

If can't get HOST_IP for a network kudmp, we just fail. Becasue most
likely any attempt to save dump will also fail.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Baoquan He 2012-12-13 13:47:56 +08:00 committed by Dave Young
parent 3f0ba9aab7
commit 3be6c1228e
2 changed files with 33 additions and 1 deletions

View File

@ -7,7 +7,8 @@ KDUMP_PATH="/var/crash"
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -c --message-level 1 -d 31"
DEFAULT_ACTION="dump_rootfs"
DATEDIR=`date +%d.%m.%y-%T`
DATEDIR=`date +%Y.%m.%d-%T`
HOST_IP='127.0.0.1'
DUMP_INSTRUCTION=""
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
KDUMP_SCRIPT_DIR="/kdumpscripts"
@ -119,11 +120,31 @@ is_ssh_dump_target()
grep -q "^ssh[[:blank:]].*@" $conf_file
}
is_nfs_dump_target()
{
grep -q "^nfs.*:" $conf_file
}
is_raw_dump_target()
{
grep -q "^raw" $conf_file
}
get_host_ip()
{
if is_nfs_dump_target || is_ssh_dump_target
then
kdumpnic=$(getarg kdumpnic=)
[ -z "$kdumpnic" ] && echo "failed to get kdumpnic!" && return 1
HOST_IP=`ip addr show dev $kdumpnic|grep 'inet '`
[ $? -ne 0 ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
HOST_IP="${HOST_IP##*inet }"
HOST_IP="${HOST_IP%%/*}"
[ -z "$HOST_IP" ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
fi
return 0
}
read_kdump_conf()
{
if [ ! -f "$conf_file" ]; then
@ -198,10 +219,19 @@ if [ -z "$CORE_COLLECTOR" ];then
fi
fi
get_host_ip
if [ $? -ne 0 ]; then
echo "get_host_ip exited with non-zero status!"
do_default_action
fi
if [ -z "$DUMP_INSTRUCTION" ]; then
add_dump_code "dump_rootfs"
fi
#refresh DATEDIR with crash host ip addr
DATEDIR="$HOST_IP-$DATEDIR"
do_kdump_pre
if [ $? -ne 0 ]; then
echo "kdump_pre script exited with non-zero status!"

View File

@ -188,6 +188,8 @@ kdump_install_net() {
fi
kdump_setup_netdev "${_netdev}"
#save netdev used for kdump as cmdline
echo "kdumpnic=${_netdev}" > ${initdir}/etc/cmdline.d/kdumpnic.conf
}
#install kdump.conf and what user specifies in kdump.conf