Created
November 3, 2021 10:40
-
-
Save simplepush/af1b9c87e9203664fbd40b7bb300175a to your computer and use it in GitHub Desktop.
Disk monitoring script that will alert you when one of your disks has little space left
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 | |
# Add this script as a cronjob | |
# Append the following line to your cronjob file (open cronjob file with `crontab -e`): | |
# @daily /path/to/disk-monitor.sh | |
SIMPLEPUSH_KEY=YourKey | |
THRESHOLD=90 | |
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read line; | |
do | |
percentage=$(echo $line | awk '{ print $1}' | cut -d'%' -f1 ) | |
disk=$(echo $line | awk '{ print $2 }' ) | |
if [ $percentage -ge $THRESHOLD ]; then | |
curl --silent --output /dev/null --data "key=$SIMPLEPUSH_KEY&title=$disk&msg=Disk usage at $percentage%!" https://api.simplepush.io/send | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment