1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-18 06:04:06 +03:00

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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2022-06-30 08:55:28 +10:00 committed by Amitay Isaacs
parent fc485feae8
commit dc7aaca889

View File

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