Package: makedumpfile Version: 1:1.6.1-1 Severity: wishlist Tags: patch Hi,
Please add support for FTP uploads (besides storing the dump locally or via SSH). A patch is attached. -- Benjamin Drung System Developer Debian & Ubuntu Developer ProfitBricks GmbH Greifswalder Str. 207 D - 10405 Berlin Email: [email protected] URL: http://www.profitbricks.com Sitz der Gesellschaft: Berlin. Registergericht: Amtsgericht Charlottenburg, HRB 125506B. Geschäftsführer: Andreas Gauger, Achim Weiss.
>From 24321941046a4a76ef0bdd6ca96faf3619210762 Mon Sep 17 00:00:00 2001 From: Benjamin Drung <[email protected]> Date: Thu, 2 Mar 2017 11:55:06 +0100 Subject: [PATCH] Add support for FTP uploads --- debian/kdump-config | 83 ++++++++++++++++++++++++++++++++++++++++++++-- debian/kdump-tools.default | 10 ++++++ 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/debian/kdump-config b/debian/kdump-config index 7582db1..b9a1b89 100755 --- a/debian/kdump-config +++ b/debian/kdump-config @@ -146,8 +146,11 @@ kdump_show() echo "NFS_TIMEO: ${NFS_TIMEO:=600}" echo "NFS_RETRANS ${NFS_RETRANS:=3}" fi + if [ -n "$FTP" ]; then + echo "FTP: $FTP" + fi - if [ -n "$SSH" ] || [ -n "$NFS" ]; then + if [ -n "$SSH" ] || [ -n "$NFS" ] || [ -n "$FTP" ]; then HOSTTAG="${HOSTTAG:=ip}" echo "HOSTTAG: $HOSTTAG" fi @@ -288,6 +291,14 @@ check_fadump_support() log_failure_msg "\$SSH and \$NFS cannot be defined concurrently" [ ! $DRY_RUN ] && exit 1; fi + if [ -n "$FTP" ] && [ -n "$SSH" ];then + log_failure_msg "\$FTP and \$SSH cannot be defined concurrently" + [ ! $DRY_RUN ] && exit 1; + fi + if [ -n "$FTP" ] && [ -n "$NFS" ];then + log_failure_msg "\$FTP and \$NFS cannot be defined concurrently" + [ ! $DRY_RUN ] && exit 1; + fi } # check_kdump_support: Other miscellaneous checks go here: @@ -613,7 +624,7 @@ define_stampdir() STAMP=$1 HOSTTAG="${HOSTTAG:=ip}" - if [ -z "$SSH" ] && [ -z "$NFS" ]; then + if [ -z "$SSH" ] && [ -z "$NFS" ] && [ -z "$FTP" ]; then echo "$KDUMP_COREDIR/$STAMP" elif [ "$HOSTTAG" = "hostname" ];then echo "$KDUMP_COREDIR/$(hostname)-$STAMP" @@ -764,6 +775,70 @@ kdump_save_core() return $ERROR } +kdump_save_core_to_ftp() +{ + KDUMP_REMOTE_HOST="$FTP" + + KDUMP_STAMP=`date +"%Y%m%d%H%M"` + KDUMP_STAMPDIR=$(define_stampdir "") + + KDUMP_COREFILE="${KDUMP_STAMPDIR}dump.$KDUMP_STAMP" + KDUMP_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP" + KDUMP_DMESGFILE="${KDUMP_STAMPDIR}dmesg.$KDUMP_STAMP" + ERROR=0 + + FTPPUT_ARGS="" + if [ -n "$FTP_USER" ]; then + FTPPUT_ARGS="$FTPPUT_ARGS -u $FTP_USER" + fi + if [ -n "$FTP_PASSWORD" ]; then + FTPPUT_ARGS="$FTPPUT_ARGS -p $FTP_PASSWORD" + fi + if [ -n "$FTP_PORT" ]; then + FTPPUT_ARGS="$FTPPUT_ARGS -P $FTP_PORT" + fi + + # Add '-F' [flatten] to MAKEDUMP_ARGS, if not there: + [ "${MAKEDUMP_ARGS#-F*}" != "${MAKEDUMP_ARGS}" ] || MAKEDUMP_ARGS="${MAKEDUMP_ARGS} -F" + log_action_msg "sending makedumpfile $MAKEDUMP_ARGS $vmcore_file via FTP to $KDUMP_REMOTE_HOST:$KDUMP_COREFILE" + makedumpfile $MAKEDUMP_ARGS $vmcore_file | busybox ftpput $FTPPUT_ARGS $KDUMP_REMOTE_HOST $KDUMP_COREFILE - + ERROR=$? + + # did we succeed? + if [ $ERROR -ne 0 ]; then + log_failure_msg "$NAME: failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_COREFILE" + logger -t $NAME "failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_COREFILE" + else + log_success_msg "$NAME: saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_COREFILE" + logger -t $NAME "saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_COREFILE" + fi + + # dump the dmesg buffer + if [ "$KDUMP_DUMP_DMESG" -eq 1 ] ; then + log_action_msg "running makedumpfile --dump-dmesg $vmcore_file $KDUMP_TMPDMESG" + makedumpfile --dump-dmesg $vmcore_file $KDUMP_TMPDMESG + ERROR=$? + if [ $ERROR -ne 0 ] ; then + log_failure_msg "$NAME: makedumpfile --dump-dmesg failed. dmesg content will be unavailable" + logger -t $NAME "makedumpfile --dump-dmesg failed. dmesg content will be unavailable" + else + busybox ftpput $FTPPUT_ARGS $KDUMP_REMOTE_HOST $KDUMP_DMESGFILE $KDUMP_TMPDMESG + ERROR=$? + fi + + # did we succeed? + if [ $ERROR == 0 ]; then + log_success_msg "$NAME: saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE" + logger -t $NAME "saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE" + else + log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE" + logger -t $NAME "failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE" + fi + fi + + return $ERROR +} + kdump_save_core_to_ssh() { KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}" @@ -947,7 +1022,9 @@ case "$1" in exit 0; ;; savecore) - if ! [ -z $SSH ];then + if [ -n "$FTP" ];then + kdump_save_core_to_ftp + elif ! [ -z $SSH ];then kdump_save_core_to_ssh else kdump_save_core diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default index c4d2659..16c0873 100644 --- a/debian/kdump-tools.default +++ b/debian/kdump-tools.default @@ -88,6 +88,11 @@ KDUMP_COREDIR="/var/crash" # (e.g. remote:/var/crash) # NFS_TIMEO - Timeout before NFS retries a request. See man nfs(5) for details. # NFS_RETRANS - Number of times NFS client retries a request. See man nfs(5) for details. +# FTP - Hostname of the FTP server. KDUMP_COREDIR will be used as path. +# FTP_USER - FTP username. A anonomous upload will be used if not set. +# FTP_PASSWORD - password for the FTP user +# FTP_PORT=21 - FTP port. Port 21 will be used by default. +# # SSH="<user at server>" # # SSH_KEY="<path>" @@ -99,3 +104,8 @@ KDUMP_COREDIR="/var/crash" # NFS_TIMEO="600" # # NFS_RETRANS="3" +# +#FTP="<server>" +#FTP_USER="" +#FTP_PASSWORD="" +#FTP_PORT=21 -- 2.9.3

