# Variables are:
#
# * family - "tcp" or "udp" or space separated list
-# default: tcp
+# default: tcp, not used with "service_check_cmd"
# * version - optional, RPC service version number
-# default is to omit to check for any version
+# default is to omit to check for any version,
+# not used with "service_check_cmd"
# * unhealthy_after - number of check fails before unhealthy
# default: 1
# * restart_every - number of check fails before restart
# * service_start_cmd - command to start service
# default: no default, must be provided if
# restart_every > 0
+# * service_check_cmd - command to check health of service
+# default is to check RPC service using rpcinfo
# * service_debug_cmd - command to debug a service after trying to stop it;
# for example, it can be useful to print stack
# traces of threads that have not exited, since
restart_every=0
service_stop_cmd=""
service_start_cmd=""
+ service_check_cmd=""
service_debug_cmd=""
# Eval line-by-line. Expands variable references in values.
family=*|version=*|\
unhealthy_after=*|restart_every=*|\
service_stop_cmd=*|service_start_cmd=*|\
- service_debug_cmd=*)
+ service_check_cmd=*|service_debug_cmd=*)
eval "$_line"
;;
_service_name="nfs_${_progname}"
- if nfs_check_rpcinfo \
- "$_progname" "$version" "$family" >/dev/null ; then
+ _ok=false
+ if [ -n "$service_check_cmd" ] ; then
+ # Using eval means variables can contain semicolon separated commands
+ if eval "$service_check_cmd" ; then
+ _ok=true
+ fi
+ else
+ if nfs_check_rpcinfo \
+ "$_progname" "$version" "$family" >/dev/null ; then
+ _ok=true
+ fi
+ fi
+
+ if $_ok ; then
if [ $unhealthy_after -ne 1 -o $restart_every -ne 0 ] ; then
ctdb_counter_init "$_service_name"
fi
Supported variables are:
* family - "tcp" or "udp" or space separated list
- default: tcp
+ default: tcp, not used with "service_check_cmd"
* version - optional, RPC service version number
- default is to omit to check for any version
+ default is to omit to check for any version,
+ not used with "service_check_cmd"
* unhealthy_after - number of check fails before unhealthy
default: 1
* restart_every - number of check fails before restart
* service_start_cmd - command to start service
default: no default, must be provided if
restart_every > 0
+* service_check_cmd - command to check health of service
+ default is to check RPC service using rpcinfo
* service_debug_cmd - command to debug a service after trying to stop it;
for example, it can be useful to print stack
traces of threads that have not exited, since
restart_every=0
service_stop_cmd=""
service_start_cmd=""
+ service_check_cmd=""
service_debug_cmd=""
# Don't bother syntax checking, eventscript does that...
#
# - 2nd argument is the NFS/RPC service being tested
#
-# rpcinfo is used on each iteration to test the availability of the
-# service
+# rpcinfo (or $service_check_cmd) is used on each iteration to test
+# the availability of the service
#
# If this is not set or null then no RPC service is checked and the
# required output is not reset on each iteration. This is useful in
shift 2
fi
if [ -n "$_rpc_service" ] ; then
- if rpcinfo -T tcp localhost "$_rpc_service" >/dev/null 2>&1 ; then
+ _ok=false
+ if [ -n "$service_check_cmd" ] ; then
+ if eval "$service_check_cmd" ; then
+ _ok=true
+ fi
+ else
+ if rpcinfo -T tcp localhost "$_rpc_service" >/dev/null 2>&1 ; then
+ _ok=true
+ fi
+ fi
+
+ if $_ok ; then
_iterate_failcount=0
else
_iterate_failcount=$(($_iterate_failcount + 1))