Fix remote_disk_info_short — parse df on remote side
Move awk parsing to the remote to avoid SSH output encoding issues that caused empty fields when parsing locally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -330,28 +330,24 @@ check_remote_disk_space() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Compact one-line disk info: "USED/TOTAL (FREE free)"
|
# Compact one-line disk info: "USED/TOTAL (FREE free) PCT"
|
||||||
|
# Parsing is done on the remote/local side to avoid SSH output issues.
|
||||||
remote_disk_info_short() {
|
remote_disk_info_short() {
|
||||||
local base="${REMOTE_BASE:-/}"
|
local base="${REMOTE_BASE:-/}"
|
||||||
local df_out=""
|
local cmd="df -h '$base' 2>/dev/null | awk 'NR>1{printf \"%s/%s (%s free) %s\", \$3, \$2, \$4, \$5}'"
|
||||||
|
local result=""
|
||||||
case "${REMOTE_TYPE:-ssh}" in
|
case "${REMOTE_TYPE:-ssh}" in
|
||||||
ssh)
|
ssh)
|
||||||
df_out=$(remote_exec "df -h '$base' 2>/dev/null | tail -1") || return 1
|
result=$(remote_exec "$cmd") || return 1
|
||||||
;;
|
;;
|
||||||
local)
|
local)
|
||||||
df_out=$(df -h "$base" 2>/dev/null | tail -1) || return 1
|
result=$(eval "$cmd") || return 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# df output: Filesystem Size Used Avail Use% Mount
|
echo "${result:-N/A}"
|
||||||
local size used avail pct
|
|
||||||
size=$(echo "$df_out" | awk '{print $2}')
|
|
||||||
used=$(echo "$df_out" | awk '{print $3}')
|
|
||||||
avail=$(echo "$df_out" | awk '{print $4}')
|
|
||||||
pct=$(echo "$df_out" | awk '{print $5}')
|
|
||||||
echo "${used}/${size} (${avail} free) ${pct}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user