eventscripts: Add new option $CTDB_MONITOR_NFS_THREAD_COUNT
[Samba.git] / ctdb / config / events.d / 60.nfs
blob53f78dfe3d5cfd355627387368bfc1814fd83a02
1 #!/bin/sh
2 # script to manage nfs in a clustered environment
4 [ -n "$CTDB_BASE" ] || \
5 export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
7 . $CTDB_BASE/functions
9 service_name="nfs"
10 service_start ()
12 startstop_nfs stop
13 startstop_nfs start
14 set_proc "sys/net/ipv4/tcp_tw_recycle" 1
16 service_stop ()
18 startstop_nfs stop
20 service_reconfigure ()
22 # if the ips have been reallocated, we must restart the lockmanager
23 # across all nodes and ping all statd listeners
24 [ -x $CTDB_BASE/statd-callout ] && {
25 $CTDB_BASE/statd-callout notify &
26 } >/dev/null 2>&1
29 nfs_check_thread_count ()
31 [ "$CTDB_MONITOR_NFS_THREAD_COUNT" = "yes" ] || return 0
33 # If $RPCNFSDCOUNT/$USE_KERNEL_NFSD_NUMBER isn't set then we could
34 # guess the default from the initscript. However, let's just
35 # assume that those using the default don't care about the number
36 # of threads and that they have switched on this feature in error.
37 _configured_threads="${RPCNFSDCOUNT:-${USE_KERNEL_NFSD_NUMBER}}"
38 [ -n "$_configured_threads" ] || return 0
40 # nfsd should be running the configured number of threads. If
41 # there are a different number of threads then tell nfsd the
42 # correct number.
43 _running_threads=$(get_proc "fs/nfsd/threads")
44 # Intentionally not arithmetic comparison - avoids extra errors
45 # when get_proc() fails...
46 if [ "$_running_threads" != "$_configured_threads" ] ; then
47 echo "Attempting to correct number of nfsd threads from ${_running_threads} to ${_configured_threads}"
48 set_proc "fs/nfsd/threads" "$_configured_threads"
52 loadconfig
54 [ "$NFS_SERVER_MODE" != "ganesha" ] || exit 0
56 ctdb_setup_service_state_dir
58 ctdb_start_stop_service
60 is_ctdb_managed_service || exit 0
62 ctdb_service_check_reconfigure
64 case "$1" in
65 init)
66 # read statd from persistent database
68 startup)
69 ctdb_service_start
72 shutdown)
73 ctdb_service_stop
76 takeip)
77 ctdb_service_set_reconfigure
80 releaseip)
81 ctdb_service_set_reconfigure
84 monitor)
85 # Check that directories for shares actually exist.
86 [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
87 exportfs -v | grep '^/' |
88 sed -r -e 's@[[:space:]]+[^[:space:]()]+\([^[:space:]()]+\)$@@' |
89 sort -u |
90 ctdb_check_directories
91 } || exit $?
93 update_tickles 2049
95 nfs_check_rpc_services
97 nfs_check_thread_count
99 # Every 10 minutes, update the statd state database for which
100 # clients need notifications
101 nfs_statd_update 600
105 ctdb_standard_event_handler "$@"
107 esac
109 exit 0