mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb-scripts: Factor out new function ctdb_counter_get()
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
9f4f1c51fc
commit
dfeb5b84fd
@ -1006,15 +1006,19 @@ ctdb_counter_incr () {
|
|||||||
# unary counting!
|
# unary counting!
|
||||||
echo -n 1 >> "$_counter_file"
|
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 () {
|
ctdb_check_counter () {
|
||||||
_msg="${1:-error}" # "error" - anything else is silent on fail
|
_msg="${1:-error}" # "error" - anything else is silent on fail
|
||||||
_op="${2:--ge}" # an integer operator supported by test
|
_op="${2:--ge}" # an integer operator supported by test
|
||||||
_limit="${3:-${service_fail_limit}}"
|
_limit="${3:-${service_fail_limit}}"
|
||||||
shift 3
|
shift 3
|
||||||
_ctdb_counter_common "$1"
|
|
||||||
|
|
||||||
# unary counting!
|
_size=$(ctdb_counter_get "$1")
|
||||||
_size=$(stat -c "%s" "$_counter_file" 2>/dev/null || echo 0)
|
|
||||||
_hit=false
|
_hit=false
|
||||||
if [ "$_op" != "%" ] ; then
|
if [ "$_op" != "%" ] ; then
|
||||||
if [ $_size $_op $_limit ] ; then
|
if [ $_size $_op $_limit ] ; then
|
||||||
|
Loading…
Reference in New Issue
Block a user