Created
January 17, 2023 10:32
-
-
Save yazanmonshed/7a4983c283903d6a93c4687cf2f5b8b7 to your computer and use it in GitHub Desktop.
Script for check desk space usage
This file contains 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/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