health-check.sh: add disk space check with OK/WARN/FAIL thresholds at 80% and 90%

This commit is contained in:
Justin Oros
2026-04-20 09:33:36 -07:00
parent 8a7fe7b4de
commit ad15498bb9

View File

@@ -48,6 +48,22 @@ if [ "$IS_SPOKE" = false ] && [ "$IS_HUB" = false ]; then
exit 1
fi
check_disk() {
header "Disk Space"
while IFS= read -r line; do
local pct mount
pct=$(echo "$line" | awk '{print $5}' | tr -d '%')
mount=$(echo "$line" | awk '{print $6}')
if [ "$pct" -ge 90 ]; then
fail "Disk usage at ${pct}% on $mount — critically low"
elif [ "$pct" -ge 80 ]; then
warn "Disk usage at ${pct}% on $mount — getting full"
else
ok "Disk usage at ${pct}% on $mount"
fi
done < <(df -h | awk 'NR>1 && $6 !~ /^(\/dev|\/sys|\/proc|\/run|\/snap)/ {print}')
}
check_common() {
header "System"
@@ -202,6 +218,7 @@ check_hub() {
}
check_common
check_disk
if [ "$IS_SPOKE" = true ]; then
check_spoke