]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Reduce length of very long lines
authorMartin Schwenke <martin@meltin.net>
Wed, 29 Jun 2022 22:55:28 +0000 (08:55 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 22 Jul 2022 06:38:32 +0000 (06:38 +0000)
Use printf to allow easier line breaks and use some early returns.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events/legacy/05.system.script

index 6555152558aaf5b8bb5a79fc82823a53d9aefd03..52864aebe2f3c83f93958f6632a4a78691c76e66 100755 (executable)
@@ -46,7 +46,10 @@ check_thresholds()
        _cache="${script_state_dir}/cache_${_t}"
        if validate_percentage "$_unhealthy_threshold" "$_thing"; then
                if [ "$_usage" -ge "$_unhealthy_threshold" ]; then
-                       echo "ERROR: ${_thing} utilization ${_usage}% >= threshold ${_unhealthy_threshold}%"
+                       printf 'ERROR: %s utilization %d%% >= threshold %d%%\n' \
+                              "$_thing" \
+                              "$_usage" \
+                              "$_unhealthy_threshold"
                        eval "$_unhealthy_callout"
                        echo "$_usage" >"$_cache"
                        exit 1
@@ -60,14 +63,22 @@ check_thresholds()
                        else
                                _prev=""
                        fi
-                       if [ "$_usage" != "$_prev" ]; then
-                               echo "WARNING: ${_thing} utilization ${_usage}% >= threshold ${_warn_threshold}%"
-                               echo "$_usage" >"$_cache"
+                       if [ "$_usage" = "$_prev" ]; then
+                               return
                        fi
+                       printf 'WARNING: %s utilization %d%% >= threshold %d%%\n' \
+                              "$_thing" \
+                              "$_usage" \
+                              "$_warn_threshold"
+                       echo "$_usage" >"$_cache"
                else
-                       if [ -r "$_cache" ]; then
-                               echo "NOTICE: ${_thing} utilization ${_usage}% < threshold ${_warn_threshold}%"
+                       if [ -r "$_cache" ]; then
+                               return
                        fi
+                       printf 'NOTICE: %s utilization %d%% < threshold %d%%\n' \
+                              "$_thing" \
+                              "$_usage" \
+                              "$_warn_threshold"
                        rm -f "$_cache"
                fi
        fi
@@ -112,7 +123,8 @@ monitor_filesystem_usage()
                _fs_usage=$(df -kP "$_fs_mount" |
                        sed -n -e 's@.*[[:space:]]\([[:digit:]]*\)%.*@\1@p')
                if [ -z "$_fs_usage" ]; then
-                       echo "WARNING: Unable to get FS utilization for ${_fs_mount}"
+                       printf 'WARNING: Unable to get FS utilization for %s\n' \
+                              "$_fs_mount"
                        continue
                fi