Created
December 6, 2018 17:29
-
-
Save bmatthewshea/12e5cc0be5795e52fb33842a888ea533 to your computer and use it in GitHub Desktop.
Watch the space on /boot
This file contains hidden or 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 | |
# Use level (80 = 80% used) | |
alertlevel=80 | |
# /boot = sda2 | |
drivewarning="/dev/sda2" | |
df -H | grep -vE '^Filesystem|tmpfs|cdrom|udev|cgmfs' | awk '{ print $5 " " $1 " " $6}' | while read output; | |
do | |
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) | |
partition=$(echo $output | awk '{ print $2 }' ) | |
partname=$(echo $output | awk '{ print $3 }' ) | |
if [ "$partition" = "$drivewarning" ] && [ $usep -ge $alertlevel ]; then | |
message="$partition ($partname) is running low on space: $usep% used - $(date)" | |
# You can mail $message or send console alerts per below (or whatever) at this point: | |
wall $message | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example crontab to check every 1/2 hour:
0 */2 * * *
/home/USER/scripts/boot-space-watcher.sh