Created
May 25, 2021 16:34
-
-
Save Xeckt/6d17d958866b15ea016fca7863760ecc to your computer and use it in GitHub Desktop.
Check disk space on system. Exclude list can include more than one drive, example given in the EXCLUDE_LIST.
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/sh | |
ALERT=90 | |
EXCLUDE_LIST="/dev/hdd1|/dev/hdd2" | |
main_prog() { | |
while read -r output; | |
do | |
usep=$(echo "$output" | awk '{ print $1}' | cut -d'%' -f1) | |
partition=$(echo "$output" | awk '{print $2}') | |
if [ "$usep" -ge "$ALERT" ] ; then | |
echo "Running out of space \"$partition ($usep%)\" on server $(hostname), $(date)" | \ | |
fi | |
done | |
} | |
if [ "$EXCLUDE_LIST" != "" ] ; then | |
df -H | grep -vE "^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}" | awk '{print $5 " " $6}' | main_prog | |
else | |
df -H | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{print $5 " " $6}' | main_prog | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment