forked from finn/tinyboard
health-check.sh: show human-readable used/total disk usage instead of percentage
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user