ctdb-scripts: Factor out new function ctdb_counter_get()
authorMartin Schwenke <martin@meltin.net>
Sat, 11 Jul 2015 01:02:54 +0000 (11:02 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 14 Jul 2015 07:57:18 +0000 (09:57 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/functions

index 4b4ac7fc2069be46b6961da8a6c451dcc432ffa7..1b9b5c441d0ffa2c5c7402850234cb00741856c4 100755 (executable)
@@ -1006,15 +1006,19 @@ ctdb_counter_incr () {
     # unary counting!
     echo -n 1 >> "$_counter_file"
 }
+ctdb_counter_get () {
+    _ctdb_counter_common "$1"
+    # unary counting!
+    stat -c "%s" "$_counter_file" 2>/dev/null || echo 0
+}
 ctdb_check_counter () {
     _msg="${1:-error}"  # "error"  - anything else is silent on fail
     _op="${2:--ge}"  # an integer operator supported by test
     _limit="${3:-${service_fail_limit}}"
     shift 3
-    _ctdb_counter_common "$1"
 
-    # unary counting!
-    _size=$(stat -c "%s" "$_counter_file" 2>/dev/null || echo 0)
+    _size=$(ctdb_counter_get "$1")
+
     _hit=false
     if [ "$_op" != "%" ] ; then
        if [ $_size $_op $_limit ] ; then