]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Move failure counters to the service state directory
authorMartin Schwenke <martin@meltin.net>
Tue, 6 Feb 2018 02:51:23 +0000 (13:51 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:24 +0000 (07:08 +0100)
Scripts that use these counters must call ctdb_setup_state_dir().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events.d/01.reclock
ctdb/config/events.d/41.httpd
ctdb/config/functions

index cceb672c8e00724d5731fa7341c0b5504f1a90aa..44e49f44507b480bcebd5bef40da55b9c84bb7b4 100755 (executable)
@@ -8,6 +8,8 @@
 
 loadconfig
 
+ctdb_setup_state_dir "service" "reclock"
+
 # If CTDB_RECOVERY_LOCK specifies a helper then exit because this
 # script can't do anything useful.
 case "$CTDB_RECOVERY_LOCK" in
index 3e45768fd92c6362038463d219a347962dcade75..adba39721347cd0581817708ab8a5875ba5efa86 100755 (executable)
@@ -23,6 +23,8 @@ suse|debian|*)
        ;;
 esac
 
+ctdb_setup_state_dir "service" "$service_name"
+
 # RHEL5 sometimes use a SIGKILL to terminate httpd, which then leaks
 # semaphores.  This is a hack to clean them up.
 cleanup_httpd_semaphore_leak() {
index 5070796a2696e103337e94375a6ae6ac06528a4c..b3b348aebe2568cfa215bbabbf055de513d10187 100755 (executable)
@@ -697,10 +697,21 @@ interface_monitor ()
 
 ########################################################
 # Simple counters
-_ctdb_counter_common () {
-    _service_name="${1:-${service_name:-${script_name}}}"
-    _counter_file="${CTDB_SCRIPT_VARDIR}/failcount/${_service_name}"
-    mkdir -p "${_counter_file%/*}" # dirname
+_ctdb_counter_common ()
+{
+       [ $# -le 1 ] || die "usage: _ctdb_counter_common [name]"
+
+       if [ $# -eq 1 ] ; then
+               _counter_name="${1}.failcount"
+       else
+               _counter_name="failcount"
+       fi
+
+       if [ -z "$script_state_dir" ] ; then
+               die "ctdb_counter_* functions need ctdb_setup_state_dir()"
+       fi
+
+       _counter_file="${script_state_dir}/${_counter_name}"
 }
 # Some code passes an argument
 # shellcheck disable=SC2120