Fix remote disk usage check returning empty percentage

Use df --output=pcent for reliable single-column output instead of
parsing multi-column df output through awk over SSH.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 07:11:18 +02:00
parent 590b87843d
commit 604437bed2

View File

@@ -294,21 +294,22 @@ get_target_remotes() {
# Returns 0 (unknown) on unsupported remote types.
remote_disk_usage_pct() {
local base="${REMOTE_BASE:-/}"
local pct_raw=""
local df_out=""
case "${REMOTE_TYPE:-ssh}" in
ssh)
pct_raw=$(remote_exec "df '$base' 2>/dev/null | tail -1 | awk '{print \$5}'" 2>/dev/null) || return 1
df_out=$(remote_exec "df --output=pcent '$base' 2>/dev/null | tail -1" 2>/dev/null) || return 1
;;
local)
pct_raw=$(df "$base" 2>/dev/null | tail -1 | awk '{print $5}') || return 1
df_out=$(df --output=pcent "$base" 2>/dev/null | tail -1) || return 1
;;
*)
echo "0"
return 0
;;
esac
# Strip the % sign
echo "${pct_raw%%%}"
# Strip whitespace and % sign
df_out="${df_out// /}"
echo "${df_out%%%}"
}
# Check remote disk space. Fail if usage >= threshold (default 95%).