Service Health Check
Check systemd services and HTTP endpoints in one pass with a non-zero exit on failure.
$ webtoolist --script disk-threshold-alert
Exit non-zero when any mounted filesystem exceeds a usage threshold.
diskalertmonitoringthresholdDependencies: df, awk
#!/usr/bin/env bash
set -euo pipefail
threshold="${THRESHOLD:-85}"
fail=0
while read -r filesystem size used avail pct mount; do
pct="${pct%\%}"
if ((pct >= threshold)); then
printf 'ALERT %3s%% used on %s (%s, %s free)\n' "$pct" "$mount" "$used" "$avail" >&2
fail=1
else
printf 'ok %3s%% used on %s\n' "$pct" "$mount"
fi
done < <(df -P -x tmpfs -x devtmpfs | tail -n +2)
exit "$fail"
./disk-threshold-alert
THRESHOLD=95 ./disk-threshold-alert
df -P gives a stable one-line-per-filesystem format, which is what the parser relies on.df -i if that has bitten you.Related scripts
Check systemd services and HTTP endpoints in one pass with a non-zero exit on failure.
Show filesystem usage and the largest directories under a path.
Show reclaimable Docker space, then prune only with an explicit flag.
Locate files above a size threshold and show them largest first.