health-check.sh: show human-readable used/total disk usage instead of percentage

This commit is contained in:
Justin Oros
2026-04-22 09:50:44 -07:00
parent 2928285143
commit 2bd8711db3

View File

@@ -62,16 +62,16 @@ check_disk() {
ok "Disk usage at ${pct}% on $mount" ok "Disk usage at ${pct}% on $mount"
fi fi
done < <(df -h | awk 'NR>1' | grep -v ' /dev' | grep -v ' /sys' | grep -v ' /proc' | grep -v ' /run' | grep -v ' /snap' | grep -v 'overlay2' | grep -v 'docker') done < <(df -h | awk 'NR>1' | grep -v ' /dev' | grep -v ' /sys' | grep -v ' /proc' | grep -v ' /run' | grep -v ' /snap' | grep -v 'overlay2' | grep -v 'docker')
local used_kb total_kb total_pct local used_human total_human total_pct
used_kb=$(df --block-size=1K / | awk 'NR==2 {print $3}') used_human=$(df -h / | awk 'NR==2 {print $3}')
total_kb=$(df --block-size=1K / | awk 'NR==2 {print $2}') total_human=$(df -h / | awk 'NR==2 {print $2}')
total_pct=$(( used_kb * 100 / total_kb )) total_pct=$(df / | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$total_pct" -ge 90 ]; then if [ "$total_pct" -ge 90 ]; then
fail "Total disk usage at ${total_pct}% (root filesystem) — critically low" fail "Total disk usage ${used_human} of ${total_human} — critically low"
elif [ "$total_pct" -ge 80 ]; then elif [ "$total_pct" -ge 80 ]; then
warn "Total disk usage at ${total_pct}% (root filesystem)" warn "Total disk usage ${used_human} of ${total_human}"
else else
ok "Total disk usage at ${total_pct}% (root filesystem)" ok "Total disk usage ${used_human} of ${total_human}"
fi fi
} }