Skip to content

Instantly share code, notes, and snippets.

@thimslugga
Created November 21, 2023 11:53
Show Gist options
  • Save thimslugga/800c86b980a97416f7023cf146f44ad9 to your computer and use it in GitHub Desktop.
Save thimslugga/800c86b980a97416f7023cf146f44ad9 to your computer and use it in GitHub Desktop.
Get notification for diskspace usage via Uptime Kuma
#!/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