Skip to content

Commit

Permalink
Merge pull request #746 from ytakeshita/fix_nfs_monitor_systemd
Browse files Browse the repository at this point in the history
Medium: nfsserver: fix monitor for systemd
  • Loading branch information
oalbrigt committed Feb 3, 2016
2 parents b148004 + 5b7476a commit 1b5e68a
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion heartbeat/nfsserver
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b5e68a

Please sign in to comment.