2 # script to manage nfs in a clustered environment
11 set_proc "sys/net/ipv4/tcp_tw_recycle" 1
17 service_reconfigure ()
21 # if the ips have been reallocated, we must restart the lockmanager
22 # across all nodes and ping all statd listeners
23 [ -x $CTDB_BASE/statd-callout ] && {
24 $CTDB_BASE/statd-callout notify &
30 [ "$NFS_SERVER_MODE" != "GANESHA" ] || exit 0
32 ctdb_setup_service_state_dir
34 statd_update_trigger="$service_state_dir/update-trigger"
35 # We want this file to always exist. The corner case is when
36 # auto-start/stop is switched off, NFS is added as a managed service
37 # some time after ctdbd is started and someone else starts the NFS
38 # service for us. In this case this file might not otherwise exist
39 # when we get to a monitor event.
40 touch "$statd_update_trigger"
42 ctdb_start_stop_service
44 is_ctdb_managed_service || exit 0
46 ctdb_service_check_reconfigure
50 # read statd from persistent database
61 ctdb_service_set_reconfigure
65 ctdb_service_set_reconfigure
69 # Check that directories for shares actually exist.
70 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
71 exportfs -v | grep '^/' |
72 sed -r -e 's@[[:space:]]+[^[:space:]()]+\([^[:space:]()]+\)$@@' |
74 ctdb_check_directories
79 # check that statd responds to rpc requests
80 # if statd is not running we try to restart it
81 # we only do this IF we have a rpc.statd command.
82 # For platforms where rpc.statd does not exist, we skip
83 # the check completely
85 which $p >/dev/null 2>/dev/null && \
86 nfs_check_rpc_service "statd" \
87 -ge 6 "verbose unhealthy" \
88 -eq 4 "verbose restart" \
91 # check that NFS responds to rpc requests
92 if [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" != "yes" ] ; then
93 nfs_check_rpc_service "knfsd" \
94 -ge 6 "verbose unhealthy" \
95 -eq 4 "verbose restart" \
99 # check that lockd responds to rpc requests
100 nfs_check_rpc_service "lockd" \
101 -ge 15 "verbose restart unhealthy" \
104 # mountd is sometimes not started correctly on RHEL5
105 nfs_check_rpc_service "mountd" \
106 -ge 10 "verbose restart:b unhealthy" \
109 # rquotad is sometimes not started correctly on RHEL5
110 # not a critical service so we dont flag the node as unhealthy
111 nfs_check_rpc_service "rquotad" \
112 -gt 0 "verbose restart:b"
114 # once every 600 seconds, update the statd state database for which
115 # clients need notifications
116 LAST_UPDATE=`stat --printf="%Y" "$statd_update_trigger"`
117 CURRENT_TIME=`date +"%s"`
118 [ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
119 touch "$statd_update_trigger"
120 $CTDB_BASE/statd-callout updatelocal &
121 $CTDB_BASE/statd-callout updateremote &
126 ctdb_standard_event_handler "$@"