Monitoring Diskspace with Uptime Kuma
Monitoring Diskspace with Uptime Kuma
Monitoring Diskspace with Uptime Kuma
- Script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
disk="/dev/mapper/ubuntu--vg-ubuntu--lv" # replace with the disk that you are monitoring
percentage=$(df -hl --total ${disk} | tail -1 | awk '{printf $5}')
threshold="80" # 80% seems reasonable, but YMMV
number=${percentage%\%*}
message="Used space on ${disk} is ${number}%"
push_url="https://status.katoteros.org/api/push/PUSHURL" # replace with Uptime Kuma Push URL ID
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
- Crontab (every 5 minutes):
*/5 * * * * PATH_TO_SCRIPT
Related Posts
This post is licensed under CC BY 4.0 by the author.