Skip to content

Instantly share code, notes, and snippets.

@yazanmonshed
Created January 17, 2023 10:32
Show Gist options
  • Save yazanmonshed/7a4983c283903d6a93c4687cf2f5b8b7 to your computer and use it in GitHub Desktop.
Save yazanmonshed/7a4983c283903d6a93c4687cf2f5b8b7 to your computer and use it in GitHub Desktop.
Script for check desk space usage
#!/bin/bash
# Set the threshold for disk space usage (in percent)
threshold=90
# Get the current disk space usage
usage=$(df / | awk '{ print $5 }' | tail -n 1 | sed 's/%//')
# Check if the usage is above the threshold
if [ $usage -gt $threshold ]; then
# Send an alert if the threshold is exceeded
echo "Error: Disk space usage is above the threshold. ${usage}" | mail -s "Alert: Low disk space" webmaster@example.com
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment