From 604437bed2409abec7ff62456aaeeaa896a9abeb Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 07:11:18 +0200 Subject: [PATCH] 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 --- lib/remotes.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/remotes.sh b/lib/remotes.sh index 8f38acc..e0557ca 100644 --- a/lib/remotes.sh +++ b/lib/remotes.sh @@ -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%).