From 5b7476a2b047a0c2cc2820b6ca5f3d18c513c0f6 Mon Sep 17 00:00:00 2001 From: ytakeshita Date: Thu, 28 Jan 2016 15:27:35 +0900 Subject: [PATCH] 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 3cec5c8e75..4b6767bfb8 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