All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu
@ 2014-08-20 11:11 Louis Bouchard
  2014-08-20 11:11 ` [PATCH 1/9] Add SSH remote dump collection mechanism Louis Bouchard
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

This set of patches implements the remote kernel crash dump capability
for Debian and Ubuntu.

With this patchset, it is possible to have the result of the makedumpfile
pass or the plain vmcore content to be sent remotely to a server running
sshd or exporting a writable NFS mountpoint.

This new functionality is similar to those currently available on other
distributions, namely RHEL and SLES.

Details on the implementation and tests can be found in the following blog
post :

 * http://caribou.kamikamamak.com/2014/05/20/remote-kernel-crash-dump-for-debian-and-ubuntu/

---

Louis Bouchard (9):
  Add SSH remote dump collection mechanism
  Implement propagate to send ssh key file to remote server
  Add comments to default/kdump-tools to outline functionality
  Add a prefix to the timestamped directory
  Add remote dump information to kdump-config show
  Add NFS remote dump collection
  Add NFS info to kdump-config show
  Reformat of the kdump-tools file
  Add check to avoid SSH and NFS being set together

 debian/kdump-config        | 249 +++++++++++++++++++++++++++++++++++++++++----
 debian/kdump-tools.default |  23 +++++
 2 files changed, 251 insertions(+), 21 deletions(-)

-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/9] Add SSH remote dump collection mechanism
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 2/9] Implement propagate to send ssh key file to remote server Louis Bouchard
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Make Error testing coherent to all sections
Add initial SSH connectivity verification to remote host
use ssh -i with explicit key location

On Ubuntu kdump-config runs as root with / as $HOME so it cannot
locate the .ssh directory. Tell the ssh commands where to find
it explicitely

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config        | 79 +++++++++++++++++++++++++++++++++++++++++++++-
 debian/kdump-tools.default |  9 ++++++
 2 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index 2e6cad9..4e283ab 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -357,6 +357,79 @@ function kdump_save_core()
 	fi
 }
 
+function kdump_save_core_to_ssh()
+{
+	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
+	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
+	KDUMP_REMOTE_HOST="$SSH"
+	KDUMP_STAMPDIR="$KDUMP_COREDIR/$KDUMP_STAMP"
+	KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete"
+	KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP"
+	KDUMP_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP"
+	KDUMP_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP"
+	ERROR=0
+
+	ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST mkdir -p $KDUMP_STAMPDIR
+	ERROR=$?
+	# If remote connections fails, no need to continue
+	if [ $ERROR -ne 0 ] ; then
+		log_failure_msg "$NAME: Unable to reach remote server $KDUMP_REMOTE_HOST. No reason to continue"
+		logger -t $NAME "Unable to reach remote server $KDUMP_REMOTE_HOST. No reason to continue"
+		return 1
+	fi
+
+	log_action_msg "sending makedumpfile $MAKEDUMP_ARGS $vmcore_file to $KDUMP_REMOTE_HOST : $KDUMP_CORETEMP"
+	makedumpfile $MAKEDUMP_ARGS $vmcore_file | ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST dd of=$KDUMP_CORETEMP
+	ERROR=$?
+	if [ $ERROR -ne 0 ] ; then
+		log_failure_msg "$NAME: makedumpfile failed, falling back to 'scp'"
+		logger -t $NAME "makedumpfile failed, falling back to 'scp'"
+		KDUMP_CORETEMP="$KDUMP_STAMPDIR/vmcore-incomplete"
+		KDUMP_COREFILE="$KDUMP_STAMPDIR/vmcore.$KDUMP_STAMP"
+		scp -i $KDUMP_SSH_KEY $vmcore_file $KDUMP_REMOTE_HOST:$KDUMP_CORETEMP
+		if [ $? -ne 0 ];then
+			log_failure_msg "$NAME: makedumpfile scp failed. The vmcore file will  not be available"
+			logger -t $NAME "makedumpfile scp failed. The vmcore file will  not be available"
+		else
+			ERROR=0
+		fi
+	else
+		ERROR=0
+	fi
+
+	# did we succeed?
+	if [ $ERROR -ne 0 ]; then
+		log_failure_msg "$NAME: failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+		logger -t $NAME "failed to save vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+	else
+		ssh -i $KDUMP_SSH_KEY $KDUMP_REMOTE_HOST mv $KDUMP_CORETEMP $KDUMP_COREFILE
+		log_success_msg "$NAME: saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+		logger -t $NAME "saved vmcore in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+	fi
+
+	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
+		scp -i $KDUMP_SSH_KEY $KDUMP_TMPDMESG $KDUMP_REMOTE_HOST:$KDUMP_DMESGFILE
+		ERROR=$?
+	fi
+
+	# did we succeed?
+	if [ $ERROR == 0 ]; then
+		log_success_msg "$NAME: saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+		logger -t $NAME "saved dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+		return 0;
+	else
+		log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+		logger -t $NAME "failed to save dmesg content in $KDUMP_REMOTE_HOST:$KDUMP_STAMPDIR"
+		return 1;
+	fi
+}
+
 
 
 case "$1" in
@@ -390,7 +463,11 @@ case "$1" in
 	exit 0;
 	;;
   savecore)
-	kdump_save_core
+	if ! [ -z $SSH ] || ! [ -z $NFS ] || [ -z NFS4 ]];then
+		kdump_save_core_to_ssh
+	else
+		kdump_save_core
+	fi
 	exit $?
 	;;
   help|-h*|--h*)
diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default
index 8d02da0..e5e3bec 100644
--- a/debian/kdump-tools.default
+++ b/debian/kdump-tools.default
@@ -63,3 +63,12 @@ KDUMP_COREDIR="/var/crash"
 
 # ---------------------------------------------------------------------------
 # Architecture specific Overrides:
+
+# ---------------------------------------------------------------------------
+# Remote dump facilities
+#
+# SSH="<user@server>"
+#
+# NFS="<nfs mount>"
+#
+# NFS4="<nfs mount>"
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/9] Implement propagate to send ssh key file to remote server
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
  2014-08-20 11:11 ` [PATCH 1/9] Add SSH remote dump collection mechanism Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 3/9] Add comments to default/kdump-tools to outline functionality Louis Bouchard
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config        | 69 ++++++++++++++++++++++++++++++++++++++--------
 debian/kdump-tools.default |  2 ++
 2 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index 4e283ab..b0164dd 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -24,6 +24,7 @@
 #	* unloading a kdump kernel
 #	* saving a vmcore kdump kernel
 #	* determining the status of kdump
+#	* propagate ssh key to remote host
 
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 NAME=${NAME:="kdump-config"}
@@ -61,17 +62,18 @@ function kdump_help()
 {
 cat <<EOHELP
 Usage:
-kdump-config {help|test|show|status|load|unload|savecore}"
-  help     - print this page
-  test     - Do a dry-run of the load command.  Show the kernels and
-             parameters that will be used and echo the kexec command.
-             The kexec command will not be executed.
-  show     - Show kdump status, kexec command, and any current parameters.
-  status   - evaluate /sys/kernel/kexec_crash_loaded and print a message
-  load     - Locate the kdump kernel, debug kernel, and establish links for
-             makedumpfile.  Then load the kdump kernel using kexec
-  unload   - unload the kdump kernel using kexec
-  savecore - use previously made links to save /proc/vmcore
+kdump-config {help|test|show|status|load|unload|savecore|propagate}"
+  help      - print this page
+  test      - Do a dry-run of the load command.  Show the kernels and
+              parameters that will be used and echo the kexec command.
+              The kexec command will not be executed.
+  show      - Show kdump status, kexec command, and any current parameters.
+  status    - evaluate /sys/kernel/kexec_crash_loaded and print a message
+  load      - Locate the kdump kernel, debug kernel, and establish links for
+              makedumpfile.  Then load the kdump kernel using kexec
+  unload    - unload the kdump kernel using kexec
+  savecore  - use previously made links to save /proc/vmcore
+  propagate - Send public ssh key to remote host for passwordless connection
 
 EOHELP
 }
@@ -430,6 +432,46 @@ function kdump_save_core_to_ssh()
 	fi
 }
 
+function kdump_propagate()
+{
+KDUMP_COREDIR=${KDUMP_COREDIR:=/var/crash}
+	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
+	KDUMP_REMOTE_HOST="$SSH"
+
+	# ssh key propagation is only needed
+	# if remote ssh dump is configured
+	if [ -z $KDUMP_REMOTE_HOST ];then
+		log_failure_msg "$NAME: Remote ssh dump is not configured. No reason to propagate"
+		logger -t $NAME "Remote ssh dump is not configured. No reason to propagate"
+		return 1;
+	fi
+
+	# Verify if the provided key exists and create it if needed
+	if [ -f $KDUMP_SSH_KEY ];then
+		echo "Using existing key $KDUMP_SSH_KEY"
+	else
+		echo "Need to generate a new ssh key..."
+		/usr/bin/ssh-keygen -t rsa -f $KDUMP_SSH_KEY -N "" 2>&1 > /dev/null
+	fi
+
+	KDUMP_SSH_USER=${KDUMP_REMOTE_HOST%@*}
+	KDUMP_SSH_TARGET=${KDUMP_REMOTE_HOST#*@}
+
+	ssh-copy-id -i $KDUMP_SSH_KEY $KDUMP_SSH_USER@$KDUMP_SSH_TARGET &>/dev/null
+	ERROR=$?
+
+	if [ $ERROR -ne 0 ];then
+		log_failure_msg "$NAME: $KDUMP_SSH_KEY failed to be sent to $KDUMP_REMOTE_HOST"
+		logger -t $NAME "$KDUMP_SSH_KEY failed to be sent to $KDUMP_REMOTE_HOST"
+		return 1;
+	else
+		logger -t $NAME "propagated ssh key $KDUMP_SSH_KEY to server $KDUMP_REMOTE_HOST"
+		echo "propagated ssh key $KDUMP_SSH_KEY to server $KDUMP_REMOTE_HOST"
+		return 0;
+	fi
+
+}
+
 
 
 case "$1" in
@@ -470,11 +512,14 @@ case "$1" in
 	fi
 	exit $?
 	;;
+  propagate)
+	kdump_propagate;
+	;;
   help|-h*|--h*)
 	kdump_help
 	;;
   *)
-	echo "Usage: $0 {help|test|show|status|load|unload|savecore}"
+	echo "Usage: $0 {help|test|show|status|load|unload|savecore|propagate}"
 	exit 1
 	;;
 esac
diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default
index e5e3bec..d870523 100644
--- a/debian/kdump-tools.default
+++ b/debian/kdump-tools.default
@@ -72,3 +72,5 @@ KDUMP_COREDIR="/var/crash"
 # NFS="<nfs mount>"
 #
 # NFS4="<nfs mount>"
+#
+# SSH_KEY="<path>"
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/9] Add comments to default/kdump-tools to outline functionality
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
  2014-08-20 11:11 ` [PATCH 1/9] Add SSH remote dump collection mechanism Louis Bouchard
  2014-08-20 11:11 ` [PATCH 2/9] Implement propagate to send ssh key file to remote server Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 4/9] Add a prefix to the timestamped directory Louis Bouchard
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config        | 1 -
 debian/kdump-tools.default | 7 ++++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index b0164dd..1184d6d 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -434,7 +434,6 @@ function kdump_save_core_to_ssh()
 
 function kdump_propagate()
 {
-KDUMP_COREDIR=${KDUMP_COREDIR:=/var/crash}
 	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
 	KDUMP_REMOTE_HOST="$SSH"
 
diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default
index d870523..8ef95b8 100644
--- a/debian/kdump-tools.default
+++ b/debian/kdump-tools.default
@@ -65,7 +65,12 @@ KDUMP_COREDIR="/var/crash"
 # Architecture specific Overrides:
 
 # ---------------------------------------------------------------------------
-# Remote dump facilities
+# Remote dump facilities:
+# SSH - username and hostname of the remote server that will receive the dump
+# 	and dmesg files.
+# SSH_KEY - Full path of the ssh private key to be used to login to the remote
+# 	    server. use kdump-config propagate to send the public key to the
+# 	    remote server
 #
 # SSH="<user@server>"
 #
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/9] Add a prefix to the timestamped directory
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
                   ` (2 preceding siblings ...)
  2014-08-20 11:11 ` [PATCH 3/9] Add comments to default/kdump-tools to outline functionality Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 5/9] Add remote dump information to kdump-config show Louis Bouchard
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

When sending the dump to a remote server, add IP address
or hostname as a prefix to the timestamped directory.
IP address is the default.

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config        | 14 ++++++++++++--
 debian/kdump-tools.default |  5 +++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index 1184d6d..d97de02 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -362,9 +362,19 @@ function kdump_save_core()
 function kdump_save_core_to_ssh()
 {
 	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
-	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
 	KDUMP_REMOTE_HOST="$SSH"
-	KDUMP_STAMPDIR="$KDUMP_COREDIR/$KDUMP_STAMP"
+	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
+	HOSTTAG="${HOSTTAG:=ip}"
+
+	if [ $HOSTTAG = "hostname" ];then
+		THIS_HOST="$(hostname)"
+	else
+		THIS_HOST="$(hostname -I)"
+		set -a $THIS_HOST
+		THIS_HOST=$1
+	fi
+
+	KDUMP_STAMPDIR="$KDUMP_COREDIR/$THIS_HOST-$KDUMP_STAMP"
 	KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete"
 	KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP"
 	KDUMP_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP"
diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default
index 8ef95b8..c391f3c 100644
--- a/debian/kdump-tools.default
+++ b/debian/kdump-tools.default
@@ -71,9 +71,14 @@ KDUMP_COREDIR="/var/crash"
 # SSH_KEY - Full path of the ssh private key to be used to login to the remote
 # 	    server. use kdump-config propagate to send the public key to the
 # 	    remote server
+# HOSTTAG - Select if hostname of IP address will be used as a prefix to the
+#           timestamped directory when sending files to the remote server.
+#           'ip' is the default.
 #
 # SSH="<user@server>"
 #
+# HOSTTAG="hostname|[ip]"
+# 
 # NFS="<nfs mount>"
 #
 # NFS4="<nfs mount>"
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/9] Add remote dump information to kdump-config show
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
                   ` (3 preceding siblings ...)
  2014-08-20 11:11 ` [PATCH 4/9] Add a prefix to the timestamped directory Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 6/9] Add NFS remote dump collection Louis Bouchard
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/debian/kdump-config b/debian/kdump-config
index d97de02..5913478 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -84,6 +84,15 @@ function kdump_show()
 	echo "KDUMP_SYSCTL:     $KDUMP_SYSCTL"
 	echo "KDUMP_COREDIR:    $KDUMP_COREDIR"
 	echo "crashkernel addr: $IOMEM_ADDR"
+	if [ -z $SSH ];then
+		echo "SSH:              local"
+	else
+		echo "SSH:              $SSH"
+	fi
+	HOSTTAG="${HOSTTAG:=ip}"
+	echo "HOSTTAG:          $HOSTTAG"
+	SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
+	echo "SSH_KEY:          $SSH_KEY"
 	if [ -e $sys_kexec_crash -a `cat $sys_kexec_crash` -eq 1 ] ; then
 		echo "current state:    ready to kdump";
 	else
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/9] Add NFS remote dump collection
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
                   ` (4 preceding siblings ...)
  2014-08-20 11:11 ` [PATCH 5/9] Add remote dump information to kdump-config show Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 7/9] Add NFS info to kdump-config show Louis Bouchard
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Refactor subdirectory definition into a function

Create define_stampdir() that will create the subdirectoy
where the dump is sent to according to the values of the
SSH, NFS and HOSTTAG variables. Nothing is added if the
dump is local
Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config | 97 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 77 insertions(+), 20 deletions(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index 5913478..2818b56 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -306,6 +306,29 @@ function kdump_unload()
 	fi
 }
 
+#
+# Return the name of the subdirectory to store core file.
+#	Will add hostname/IP according to the value of
+#	HOSTTAG if networked dump is selected
+
+function define_stampdir()
+{
+	STAMP=$1
+	HOSTTAG="${HOSTTAG:=ip}"
+
+	if [ -z "$SSH" ] && [ -z "$NFS" ]; then
+		echo "$KDUMP_COREDIR/$STAMP"
+	elif [ $HOSTTAG = "hostname" ];then
+		echo "$KDUMP_COREDIR/$(hostname)-$STAMP"
+	else
+		THIS_HOST="$(hostname -I)"
+		set -a $THIS_HOST
+		THIS_HOST=$1
+		echo "$KDUMP_COREDIR/$THIS_HOST-$STAMP"
+	fi
+}
+
+
 # Saving the vmcore:
 #	Our priorities are:
 #	  1. If the makedumpfile config link is valid, use that
@@ -313,33 +336,64 @@ function kdump_unload()
 #	  3. else fallback to using:  makedumpfile -d 1 -c
 #	  4. else use cp
 #
-# TODO: implement different transport options other than
-# store to local disk
-#
 # Returns: 0/1 (success/fail)
 # Sets: KDUMP_STAMPDIR, KDUMP_COREFILE
 function kdump_save_core()
 {
 	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
-	KDUMP_STAMPDIR="$KDUMP_COREDIR/$KDUMP_STAMP"
+	KDUMP_STAMPDIR=$(define_stampdir $KDUMP_STAMP)
 	KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete"
 	KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP"
 	KDUMP_DMESGFILE="$KDUMP_STAMPDIR/dmesg.$KDUMP_STAMP"
 
-	mkdir -p $KDUMP_STAMPDIR
+	# If we use NFS, verify that we can mount the FS
+	#
+	if [ -n "$NFS" ];then
+		log_action_msg "Mounting NFS mountpoint $NFS ..."
+		mount -t nfs -o nolock -o tcp -o soft -o timeo=5 -o retrans=5 $NFS $KDUMP_COREDIR
+		ERROR=$?
+		if [ $ERROR -ne 0 ];then
+			log_failure_msg "$NAME: Unable to mount remote NFS directory $NFS. Cannot save core"
+			logger -t $NAME "Unable to mount remote NFS directory $NFS. Cannot save core"
+			return 1;
+		fi
+
+		# FS is mounted, see if we can write to it
+		#
+		mkdir -p $KDUMP_STAMPDIR
+		ERROR=$?
+
+		if [ $ERROR -ne 0 ];then
+			log_failure_msg "$NAME: Unable to write to the remote NFS directory $NFS. Cannot save core"
+			logger -t $NAME "Unable to write to the remote NFS directory $NFS. Cannot save core"
+			umount $KDUMP_COREDIR
+			UMNT_ERROR=$?
+			if [ $UMNT_ERROR -ne 0 ];then
+				log_failure_msg "$NAME: Unable to cleanly unmount the NFS file system"
+				logger -t $NAME "Unable to cleanly unmount the NFS file system"
+			fi
+		else
+			log_action_msg "Dumping to NFS mountpoint $NFS/$KDUMP_STAMP"
+			logger -t $NAME "Dumping to NFS mountpoint $NFS/$KDUMP_STAMP"
+		fi
+	else
+		mkdir -p $KDUMP_STAMPDIR
+	fi
 
 	log_action_msg "running makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP"
 	makedumpfile $MAKEDUMP_ARGS $vmcore_file $KDUMP_CORETEMP
-	if [ $? -ne 0 ] ; then
+	ERROR=$?
+	if [ $ERROR -ne 0 ] ; then
 		log_failure_msg "$NAME: makedumpfile failed, falling back to 'cp'"
 		logger -t $NAME "makedumpfile failed, falling back to 'cp'"
 		KDUMP_CORETEMP="$KDUMP_STAMPDIR/vmcore-incomplete"
 		KDUMP_COREFILE="$KDUMP_STAMPDIR/vmcore.$KDUMP_STAMP"
 		cp $vmcore_file $KDUMP_CORETEMP
+		ERROR=$?
 	fi
 
 	# did we succeed?
-	if [ $? == 0 ]; then
+	if [ $ERROR == 0 ]; then
 		mv $KDUMP_CORETEMP $KDUMP_COREFILE
 		log_success_msg "$NAME: saved vmcore in $KDUMP_STAMPDIR"
 		logger -t $NAME "saved vmcore in $KDUMP_STAMPDIR"
@@ -360,30 +414,33 @@ function kdump_save_core()
 	if [ $ERROR == 0 ]; then
 		log_success_msg "$NAME: saved dmesg content in $KDUMP_STAMPDIR"
 		logger -t $NAME "saved dmesg content in $KDUMP_STAMPDIR"
-		return 0;
 	else
 		log_failure_msg "$NAME: failed to save dmesg content in $KDUMP_STAMPDIR"
 		logger -t $NAME "failed to save dmesg content in $KDUMP_STAMPDIR"
-		return 1;
 	fi
+
+	# If we use NFS, umount the remote FS
+	#
+	if [ -n "$NFS" ];then
+		umount $KDUMP_COREDIR
+		UMNT_ERROR=$?
+		if [ $UMNT_ERROR -ne 0 ] ; then
+			log_failure_msg "$NAME: Unable to cleanly unmount the NFS file system"
+			logger -t $NAME "Unable to cleanly unmount the NFS file system"
+		fi
+	fi
+
+	return $ERROR
 }
 
 function kdump_save_core_to_ssh()
 {
 	KDUMP_SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
 	KDUMP_REMOTE_HOST="$SSH"
-	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
-	HOSTTAG="${HOSTTAG:=ip}"
 
-	if [ $HOSTTAG = "hostname" ];then
-		THIS_HOST="$(hostname)"
-	else
-		THIS_HOST="$(hostname -I)"
-		set -a $THIS_HOST
-		THIS_HOST=$1
-	fi
+	KDUMP_STAMP=`date +"%Y%m%d%H%M"`
+	KDUMP_STAMPDIR=$(define_stampdir $KDUMP_STAMP)
 
-	KDUMP_STAMPDIR="$KDUMP_COREDIR/$THIS_HOST-$KDUMP_STAMP"
 	KDUMP_CORETEMP="$KDUMP_STAMPDIR/dump-incomplete"
 	KDUMP_COREFILE="$KDUMP_STAMPDIR/dump.$KDUMP_STAMP"
 	KDUMP_TMPDMESG="/tmp/dmesg.$KDUMP_STAMP"
@@ -523,7 +580,7 @@ case "$1" in
 	exit 0;
 	;;
   savecore)
-	if ! [ -z $SSH ] || ! [ -z $NFS ] || [ -z NFS4 ]];then
+	if ! [ -z $SSH ];then
 		kdump_save_core_to_ssh
 	else
 		kdump_save_core
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/9] Add NFS info to kdump-config show
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
                   ` (5 preceding siblings ...)
  2014-08-20 11:11 ` [PATCH 6/9] Add NFS remote dump collection Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 8/9] Reformat of the kdump-tools file Louis Bouchard
  2014-08-20 11:11 ` [PATCH 9/9] Add check to avoid SSH and NFS being set together Louis Bouchard
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Add NFS details and reorganize to make it conditional

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/debian/kdump-config b/debian/kdump-config
index 2818b56..37932ac 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -84,15 +84,21 @@ function kdump_show()
 	echo "KDUMP_SYSCTL:     $KDUMP_SYSCTL"
 	echo "KDUMP_COREDIR:    $KDUMP_COREDIR"
 	echo "crashkernel addr: $IOMEM_ADDR"
-	if [ -z $SSH ];then
-		echo "SSH:              local"
-	else
+
+	if [ -n "$SSH" ];then
 		echo "SSH:              $SSH"
+		SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
+		echo "SSH_KEY:          $SSH_KEY"
 	fi
-	HOSTTAG="${HOSTTAG:=ip}"
-	echo "HOSTTAG:          $HOSTTAG"
-	SSH_KEY="${SSH_KEY:=/root/.ssh/kdump_id_rsa}"
-	echo "SSH_KEY:          $SSH_KEY"
+	if [ -n "$NFS" ]; then
+		echo "NFS:              $NFS"
+	fi
+
+	if [ -n "$SSH" ] || [ -n "$NFS" ]; then
+		HOSTTAG="${HOSTTAG:=ip}"
+		echo "HOSTTAG:          $HOSTTAG"
+	fi
+
 	if [ -e $sys_kexec_crash -a `cat $sys_kexec_crash` -eq 1 ] ; then
 		echo "current state:    ready to kdump";
 	else
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/9] Reformat of the kdump-tools file
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
                   ` (6 preceding siblings ...)
  2014-08-20 11:11 ` [PATCH 7/9] Add NFS info to kdump-config show Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  2014-08-20 11:11 ` [PATCH 9/9] Add check to avoid SSH and NFS being set together Louis Bouchard
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-tools.default | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/debian/kdump-tools.default b/debian/kdump-tools.default
index c391f3c..3da5343 100644
--- a/debian/kdump-tools.default
+++ b/debian/kdump-tools.default
@@ -74,13 +74,15 @@ KDUMP_COREDIR="/var/crash"
 # HOSTTAG - Select if hostname of IP address will be used as a prefix to the
 #           timestamped directory when sending files to the remote server.
 #           'ip' is the default.
+# NFS -     Hostname and mount point of the NFS server configured to receive
+#           the crash dump. The syntax must be {HOSTNAME}:{MOUNTPOINT} 
+#           (e.g. remote:/var/crash)
 #
 # SSH="<user@server>"
 #
+# SSH_KEY="<path>"
+#
 # HOSTTAG="hostname|[ip]"
 # 
 # NFS="<nfs mount>"
 #
-# NFS4="<nfs mount>"
-#
-# SSH_KEY="<path>"
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 9/9] Add check to avoid SSH and NFS being set together
  2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
                   ` (7 preceding siblings ...)
  2014-08-20 11:11 ` [PATCH 8/9] Reformat of the kdump-tools file Louis Bouchard
@ 2014-08-20 11:11 ` Louis Bouchard
  8 siblings, 0 replies; 10+ messages in thread
From: Louis Bouchard @ 2014-08-20 11:11 UTC (permalink / raw)
  To: kexec

Signed-off-by: Louis Bouchard <louis.bouchard@ubuntu.com>
---
 debian/kdump-config | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/debian/kdump-config b/debian/kdump-config
index 37932ac..9ff9892 100755
--- a/debian/kdump-config
+++ b/debian/kdump-config
@@ -152,6 +152,10 @@ function check_kdump_support()
 		log_failure_msg "no crashkernel= parameter in the kernel cmdline"
 		[ ! $DRY_RUN ] && exit 1;
 	fi
+        if [ -n "$NFS" ] && [ -n "$SSH" ];then
+		log_failure_msg "\$SSH and \$NFS cannot be define concurrently"
+		[ ! $DRY_RUN ] && exit 1;
+	fi
 }
 
 # check_relocatable: check if the given kernel config is relocatable
-- 
1.9.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-08-20 11:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 11:11 [PATCH 0/9] Remote kernel crash dump for Debian and Ubuntu Louis Bouchard
2014-08-20 11:11 ` [PATCH 1/9] Add SSH remote dump collection mechanism Louis Bouchard
2014-08-20 11:11 ` [PATCH 2/9] Implement propagate to send ssh key file to remote server Louis Bouchard
2014-08-20 11:11 ` [PATCH 3/9] Add comments to default/kdump-tools to outline functionality Louis Bouchard
2014-08-20 11:11 ` [PATCH 4/9] Add a prefix to the timestamped directory Louis Bouchard
2014-08-20 11:11 ` [PATCH 5/9] Add remote dump information to kdump-config show Louis Bouchard
2014-08-20 11:11 ` [PATCH 6/9] Add NFS remote dump collection Louis Bouchard
2014-08-20 11:11 ` [PATCH 7/9] Add NFS info to kdump-config show Louis Bouchard
2014-08-20 11:11 ` [PATCH 8/9] Reformat of the kdump-tools file Louis Bouchard
2014-08-20 11:11 ` [PATCH 9/9] Add check to avoid SSH and NFS being set together Louis Bouchard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.