mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ctdb-scripts: Remove old NFS checking code
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
74428e5c14
commit
49c4d1900c
@ -258,216 +258,6 @@ program_stack_traces ()
|
||||
done
|
||||
}
|
||||
|
||||
######################################################
|
||||
# Check that an RPC service is healthy -
|
||||
# this includes allowing a certain number of failures
|
||||
# before marking the NFS service unhealthy.
|
||||
#
|
||||
# usage: nfs_check_rpc_service SERVICE_NAME [ triple ...]
|
||||
#
|
||||
# each triple is a set of 3 arguments: an operator, a
|
||||
# fail count limit and an action string.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# nfs_check_rpc_service "lockd" \
|
||||
# -ge 15 "verbose restart unhealthy" \
|
||||
# -eq 10 "restart:bs"
|
||||
#
|
||||
# says that if lockd is down for 15 iterations then do
|
||||
# a verbose restart of lockd and mark the node unhealthy.
|
||||
# Before this, after 10 iterations of failure, the
|
||||
# service is restarted silently in the background.
|
||||
# Order is important: the number of failures need to be
|
||||
# specified in reverse order because processing stops
|
||||
# after the first condition that is true.
|
||||
######################################################
|
||||
nfs_check_rpc_service ()
|
||||
{
|
||||
_prog_name="$1" ; shift
|
||||
|
||||
if _nfs_check_rpc_common "$_prog_name" ; then
|
||||
return
|
||||
fi
|
||||
|
||||
while [ -n "$3" ] ; do
|
||||
if _nfs_check_rpc_action "$1" "$2" "$3" ; then
|
||||
break
|
||||
fi
|
||||
shift 3
|
||||
done
|
||||
}
|
||||
|
||||
# The new way of doing things...
|
||||
nfs_check_rpc_services ()
|
||||
{
|
||||
# Files must end with .check - avoids editor backups, RPM fu, ...
|
||||
for _f in "${CTDB_BASE}/nfs-rpc-checks.d/"[0-9][0-9].*.check ; do
|
||||
_t="${_f%.check}"
|
||||
_prog_name="${_t##*/[0-9][0-9].}"
|
||||
|
||||
# If $_prog_name contains '@' then the bit after it is the
|
||||
# address family.
|
||||
_family="${_prog_name#*@}"
|
||||
if [ "$_family" = "$_prog_name" ] ; then
|
||||
_family=""
|
||||
else
|
||||
_prog_name="${_prog_name%@*}"
|
||||
fi
|
||||
|
||||
if _nfs_check_rpc_common "$_prog_name" "$_family" ; then
|
||||
# This RPC service is up, check next service...
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check each line in the file in turn until one of the limit
|
||||
# checks is hit...
|
||||
while read _cmp _lim _rest ; do
|
||||
# Skip comments
|
||||
case "$_cmp" in
|
||||
\#*) continue ;;
|
||||
esac
|
||||
|
||||
if _nfs_check_rpc_action "$_cmp" "$_lim" "$_rest" ; then
|
||||
# Limit was hit on this line, no further checking...
|
||||
break
|
||||
fi
|
||||
done <"$_f"
|
||||
done
|
||||
}
|
||||
|
||||
_nfs_check_rpc_common ()
|
||||
{
|
||||
_prog_name="$1"
|
||||
_family="$2"
|
||||
|
||||
# Some platforms don't have separate programs for all services.
|
||||
case "$_prog_name" in
|
||||
statd)
|
||||
type "rpc.${_prog_name}" >/dev/null 2>&1 || return 0
|
||||
esac
|
||||
|
||||
case "$_prog_name" in
|
||||
nfsd)
|
||||
_rpc_prog=nfs
|
||||
_version=3
|
||||
;;
|
||||
mountd)
|
||||
_rpc_prog=mountd
|
||||
_version=1
|
||||
;;
|
||||
rquotad)
|
||||
_rpc_prog=rquotad
|
||||
_version=1
|
||||
;;
|
||||
lockd)
|
||||
_rpc_prog=nlockmgr
|
||||
_version=4
|
||||
;;
|
||||
statd)
|
||||
_rpc_prog=status
|
||||
_version=1
|
||||
;;
|
||||
*)
|
||||
echo "Internal error: unknown RPC program \"$_prog_name\"."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
_service_name="nfs_${_prog_name}${_family:+_}${_family}"
|
||||
|
||||
if ctdb_check_rpc "$_rpc_prog" "$_version" "$_family" >/dev/null ; then
|
||||
ctdb_counter_init "$_service_name"
|
||||
return 0
|
||||
fi
|
||||
|
||||
ctdb_counter_incr "$_service_name"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
_nfs_check_rpc_action ()
|
||||
{
|
||||
_cmp="$1"
|
||||
_limit="$2"
|
||||
_actions="$3"
|
||||
|
||||
if ctdb_check_counter "quiet" "$_cmp" "$_limit" "$_service_name" ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
for _action in $_actions ; do
|
||||
case "$_action" in
|
||||
verbose)
|
||||
echo "ERROR: $ctdb_check_rpc_out"
|
||||
;;
|
||||
restart)
|
||||
_nfs_restart_rpc_service "$_prog_name"
|
||||
;;
|
||||
restart:b)
|
||||
_nfs_restart_rpc_service "$_prog_name" true
|
||||
;;
|
||||
unhealthy)
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "Internal error: unknown action \"$_action\"."
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_nfs_restart_rpc_service ()
|
||||
{
|
||||
_prog_name="$1"
|
||||
_background="${2:-false}"
|
||||
|
||||
if $_background ; then
|
||||
_maybe_background="background_with_logging"
|
||||
else
|
||||
_maybe_background=""
|
||||
fi
|
||||
|
||||
_p="rpc.${_prog_name}"
|
||||
|
||||
case "$_prog_name" in
|
||||
nfsd)
|
||||
echo "Trying to restart NFS service"
|
||||
$_maybe_background startstop_nfs restart
|
||||
;;
|
||||
mountd)
|
||||
echo "Trying to restart $_prog_name [${_p}]"
|
||||
killall -q -9 "$_p"
|
||||
nfs_dump_some_threads "$_p"
|
||||
$_maybe_background $_p $RPCMOUNTDOPTS \
|
||||
${MOUNTD_PORT:+-p} $MOUNTD_PORT
|
||||
;;
|
||||
rquotad)
|
||||
echo "Trying to restart $_prog_name [${_p}]"
|
||||
killall -q -9 "$_p"
|
||||
nfs_dump_some_threads "$_p"
|
||||
$_maybe_background $_p ${RQUOTAD_PORT:+-p} $RQUOTAD_PORT
|
||||
;;
|
||||
lockd)
|
||||
echo "Trying to restart lock manager service"
|
||||
$_maybe_background startstop_nfslock restart
|
||||
;;
|
||||
statd)
|
||||
echo "Trying to restart $_prog_name [${_p}]"
|
||||
killall -q -9 "$_p"
|
||||
nfs_dump_some_threads "$_p"
|
||||
$_maybe_background $_p \
|
||||
${STATD_HOSTNAME:+-n} $STATD_HOSTNAME \
|
||||
${STATD_PORT:+-p} $STATD_PORT \
|
||||
${STATD_OUTGOING_PORT:+-o} $STATD_OUTGOING_PORT
|
||||
;;
|
||||
*)
|
||||
echo "Internal error: unknown RPC program \"$_prog_name\"."
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
######################################################
|
||||
# Check the health of NFS services
|
||||
#
|
||||
|
@ -1,2 +0,0 @@
|
||||
-ge 6 verbose restart:b unhealthy
|
||||
% 2 verbose restart:b
|
@ -1,2 +0,0 @@
|
||||
% 10 verbose restart:b unhealthy
|
||||
-ge 2 verbose unhealthy
|
@ -1,2 +0,0 @@
|
||||
-ge 6 verbose restart:b unhealthy
|
||||
% 2 verbose restart:b
|
@ -1,2 +0,0 @@
|
||||
-ge 6 verbose restart:b unhealthy
|
||||
% 2 verbose restart:b
|
@ -1,2 +0,0 @@
|
||||
-ge 6 verbose restart:b unhealthy
|
||||
% 2 verbose restart:b
|
@ -1 +0,0 @@
|
||||
../../../config/nfs-rpc-checks.d
|
Loading…
Reference in New Issue
Block a user