ctdb-scripts: Improve error messages when using NFS service_check_cmd
authorMartin Schwenke <martin@meltin.net>
Wed, 20 Apr 2016 05:19:45 +0000 (15:19 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Apr 2016 05:10:14 +0000 (07:10 +0200)
When external monitoring is enabled for an NFS service using
service_check_cmd then $ctdb_check_rpc_out is empty because the
internal RPC checking isn't used.  This results in empty log messages
like:

  60.nfs: ERROR:

or:

  60.nfs: WARNING:

Improve this so it at least says:

  60.nfs: ERROR: monitoring service "statd" failed

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events.d/60.nfs

index d6b978fbf9a98ffffb0ecd13325e7fc6eee3e224..c25b73e0cd311febbcba48bbd4b0755e42633f95 100755 (executable)
@@ -168,11 +168,15 @@ nfs_check_service ()
            # Using eval means variables can contain semicolon separated commands
            if eval "$service_check_cmd" ; then
                _ok=true
+           else
+               _err="monitoring service \"${_progname}\" failed"
            fi
        else
            if nfs_check_rpcinfo \
                   "$_progname" "$version" "$family" >/dev/null ; then
                _ok=true
+           else
+               _err="$ctdb_check_rpc_out"
            fi
        fi
 
@@ -190,14 +194,14 @@ nfs_check_service ()
        if [ $unhealthy_after -gt 0 ] ; then
            if [ $_failcount -ge $unhealthy_after ] ; then
                _unhealthy=true
-               echo "ERROR: $ctdb_check_rpc_out"
+               echo "ERROR: $_err"
            fi
        fi
 
        if [ $restart_every -gt 0 ] ; then
            if [ $(($_failcount % $restart_every)) -eq 0 ] ; then
                if ! $_unhealthy ; then
-                   echo "WARNING: $ctdb_check_rpc_out"
+                   echo "WARNING: $_err"
                fi
                nfs_restart_service
            fi