eventscripts: New function nfs_check_rpc_services()
authorMartin Schwenke <martin@meltin.net>
Mon, 22 Apr 2013 20:42:54 +0000 (06:42 +1000)
committerMartin Schwenke <martin@meltin.net>
Mon, 6 May 2013 10:40:58 +0000 (20:40 +1000)
This is intended to replace nfs_check_rpc_service(), which builds
configuration into eventscripts.

nfs_check_rpc_services() uses a directory of configuration checks that
can be edited by an administrator.  The files have one limit check and
a set of actions per line.  The program name is extracted from the
file name.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/functions

index a2d9c7a39cda274308f7f95ec104df808d3d8d0d..1d4a318056643444b474886798cf9b0190039821 100755 (executable)
@@ -235,6 +235,35 @@ nfs_check_rpc_service ()
     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 _nfs_check_rpc_common "$_prog_name" ; 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"