File 0009-Medium-nfsserver-fix-monitor-for-systemd.patch of Package resource-agents.2497

From 66d68c56eeb14557317f18caf0b61aaf869f7a39 Mon Sep 17 00:00:00 2001
From: ytakeshita <y.takeshita0311@gmail.com>
Date: Thu, 28 Jan 2016 15:27:35 +0900
Subject: [PATCH 9/9] Medium: nfsserver: fix monitor for systemd

use the number of nfsd threads for monitor instead of systemctl when using systemctl and running nfsd process.
The systemctl doesn't monitor the running kernel process like nfsd.
So if nfsd process is failure, nfsserver_monitor doesn't detect it.
---
 heartbeat/nfsserver | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/heartbeat/nfsserver b/heartbeat/nfsserver
index 3cec5c8..4b6767b 100755
--- a/heartbeat/nfsserver
+++ b/heartbeat/nfsserver
@@ -293,10 +293,42 @@ v3locking_exec()
 	fi
 }
 
+nfsserver_systemd_monitor()
+{
+	local threads_num
+	local rc
+
+	nfs_exec is-active
+	rc=$?
+
+	# Now systemctl is-active can't detect the failure of kernel process like nfsd.
+	# So, if the return value of systemctl is-active is 0, check the threads number
+	# to make sure the process is running really.
+	# /proc/fs/nfsd/threads has the numbers of the nfsd threads.
+	if [ $rc -eq 0 ]; then
+		threads_num=`cat /proc/fs/nfsd/threads 2>/dev/null`
+		if [ $? -eq 0 ]; then
+			if [ $threads_num -gt 0 ]; then
+				return $OCF_SUCCESS
+			else
+				return 3
+			fi
+		else
+			return $OCF_ERR_GENERIC
+		fi
+	fi
+
+	return $rc
+}
+
 nfsserver_monitor ()
 {
+	set_exec_mode
 	fn=`mktemp`
-	nfs_exec status > $fn 2>&1 
+	case $EXEC_MODE in
+               1) nfs_exec status > $fn 2>&1;;
+            [23]) nfsserver_systemd_monitor > $fn 2>&1;;
+	esac
 	rc=$?
 	ocf_log debug "$(cat $fn)"
 	rm -f $fn
-- 
2.6.2

openSUSE Build Service is sponsored by