Skip to content

Instantly share code, notes, and snippets.

@mcnemesis
Created November 26, 2012 14:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcnemesis/4148557 to your computer and use it in GitHub Desktop.
Save mcnemesis/4148557 to your computer and use it in GitHub Desktop.
linux : mail-report on low disk-space in one line!
df -h | grep -e "/home$" | awk '{print $5}' | tr '%' ' ' | xargs -n 1 -I{} echo {} | xargs -n1 -I_percent -- sh -c '[ _percent -ge 70 ] && echo "Low Space on server:/home (_percent% full)" | mail -s "Disk Space Alert" johndoe@site.com'
@mcnemesis
Copy link
Author

Note that this one monitors just one partition (/home in this case), and then also alerts on the >=70% full condition only. So, you might want to customize those params, and also specify your own custom message and destination email address.

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