Skip to content

Instantly share code, notes, and snippets.

@urbels
Created March 21, 2016 13:45
Show Gist options
  • Save urbels/a1ef6b1e8342510ea365 to your computer and use it in GitHub Desktop.
Save urbels/a1ef6b1e8342510ea365 to your computer and use it in GitHub Desktop.
#!/bin/bash
CURRENT=$(/usr/bin/quota | awk '{print $2,$3}' | awk 'NR==3{print}' | awk '{print $1}')
MAX=$(/usr/bin/quota | awk '{print $2,$3}' | awk 'NR==3{print}' | awk '{print $2}')
x=$CURRENT
y=$MAX
z=$((x*100/y))
THRESHOLD=60
if [ "$z" -gt "$THRESHOLD" ] ; then
/usr/sbin/sendmail example@example.com << EOF
Subject: Disk space alert
Disk quota reached $THRESHOLD%. Current quota: $CURRENT
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment