forked from finn/tinyboard
health-check.sh: add disk space check with OK/WARN/FAIL thresholds at 80% and 90%
This commit is contained in:
@@ -48,6 +48,22 @@ if [ "$IS_SPOKE" = false ] && [ "$IS_HUB" = false ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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() {
|
check_common() {
|
||||||
header "System"
|
header "System"
|
||||||
|
|
||||||
@@ -202,6 +218,7 @@ check_hub() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_common
|
check_common
|
||||||
|
check_disk
|
||||||
|
|
||||||
if [ "$IS_SPOKE" = true ]; then
|
if [ "$IS_SPOKE" = true ]; then
|
||||||
check_spoke
|
check_spoke
|
||||||
|
|||||||
Reference in New Issue
Block a user