Created
November 21, 2023 11:53
-
-
Save thimslugga/800c86b980a97416f7023cf146f44ad9 to your computer and use it in GitHub Desktop.
Get notification for diskspace usage via Uptime Kuma
This file contains hidden or 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
#!/usr/bin/env bash | |
# https://gist.github.com/Eising/8620880440016b9227bc31abeca8b1ac | |
push_url="https://my.uptime.kuma.server/api/push/PUSHURL" | |
disk="/dev/sda1" # replace with the disk that you are monitoring | |
threshold="80" # 80% seems reasonable, but YMMV | |
percentage=$(df -hl --total ${disk} | tail -1 | awk '{printf $5}') | |
number=${percentage%\%*} | |
message="Used space on ${disk} is ${number}%" | |
if [ $number -lt $threshold ]; then | |
service_status="up" | |
else | |
service_status="down" | |
fi | |
curl \ | |
--get \ | |
--data-urlencode "status=${service_status}" \ | |
--data-urlencode "msg=${message}" \ | |
--data-urlencode "ping=${number}" \ | |
--silent \ | |
${push_url} \ | |
> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment