From: Martin Schwenke Date: Wed, 29 Jun 2022 22:55:28 +0000 (+1000) Subject: ctdb-scripts: Reduce length of very long lines X-Git-Tag: tevent-0.13.0~57 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc7aaca889a3a4d6d20b8091324ecc50e0a5a1e6;p=thirdparty%2Fsamba.git ctdb-scripts: Reduce length of very long lines Use printf to allow easier line breaks and use some early returns. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/events/legacy/05.system.script b/ctdb/config/events/legacy/05.system.script index 6555152558a..52864aebe2f 100755 --- a/ctdb/config/events/legacy/05.system.script +++ b/ctdb/config/events/legacy/05.system.script @@ -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