Skip to content

Instantly share code, notes, and snippets.

@bmatthewshea
Created December 6, 2018 17:29
Show Gist options
  • Save bmatthewshea/12e5cc0be5795e52fb33842a888ea533 to your computer and use it in GitHub Desktop.
Save bmatthewshea/12e5cc0be5795e52fb33842a888ea533 to your computer and use it in GitHub Desktop.
Watch the space on /boot
#!/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
@bmatthewshea
Copy link
Author

bmatthewshea commented Dec 6, 2018

example crontab to check every 1/2 hour:

0 */2 * * *    /home/USER/scripts/boot-space-watcher.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment