Created
November 14, 2012 09:19
-
-
Save ormaaj/4071150 to your computer and use it in GitHub Desktop.
filesystem size example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# GNU stat(1) required! | |
typeset -a filesystems | |
disk_space_threshold=85 | |
hsummary= | |
filesystems=(/ /DB-Backup) | |
function checkFS { | |
typeset fs= | |
typeset -i fspct= | |
for fs; do | |
if [[ -e "$fs" ]]; then | |
fspct=$(stat -fc "(%a*100)/%b" "$fs") || return 1 | |
if (( (100 - fspct) > disk_space_threshold )); then | |
LC_TIME=C printf '%(%a %b %e %H:%M:%S %Z %Y)T\t** Low Disk Space **\t on %s' -1 "$fs" | |
fi | |
else | |
return 1 | |
fi | |
done | |
} | |
if ! checkFS "${filesystems[@]}" >>"$hsummary"; then | |
echo "Error in checkFS" >&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment