commit 30152c84eafa1ed468d3d3179ae70200e7e71454 Author: Skylar Ittner Date: Sun Aug 31 14:58:03 2025 -0600 Add uptimekuma.sh diff --git a/uptimekuma.sh b/uptimekuma.sh new file mode 100644 index 0000000..7c4b03a --- /dev/null +++ b/uptimekuma.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +API_URL="https://status.netsyms.net/api/push/" +HEARTBEAT_KEY="" +ZFS_KEY="" +DISK_KEY="" +DISK_FULL_ALERT_PERCENT_THRESHOLD=85 + +# Heartbeat +echo "Sending heartbeat" +curl "$API_URL$HEARTBEAT_KEY?status=up" +echo + +# ZFS health +echo "Sending ZFS health" +zpool status -x | grep -q "all pools are healthy" && curl "$API_URL$ZFS_KEY?status=up&msg=ZFS%20Healthy" || curl -G --data-urlencode "status=down" --data-urlencode "msg=$(zpool status -x)" "$API_URL$ZFS_KEY" +echo + +# Disk usage +echo "Sending disk usage" +DISKSOK=1 +USAGES=() +while read -r output; +do + partition=$(echo "$output" | awk '{ print $2 }') + percent=$(echo "$output" | awk '{ print $1 }' | cut -d'%' -f1) + if [ $percent -ge $DISK_FULL_ALERT_PERCENT_THRESHOLD ]; then + USAGES+="$partition: $percent%" + DISKSOK=0 + fi +done <<< $(df | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{ print $5 " " $1 }') +USAGETEXT=$(IFS=,; echo "${USAGES[*]}") +echo $USAGETEXT +if [[ "$DISKSOK" == 1 ]]; then + curl "$API_URL$DISK_KEY?status=up" + echo +else + curl -G --data-urlencode "status=down" --data-urlencode "msg=$USAGETEXT" "$API_URL$DISK_KEY" + echo +fi \ No newline at end of file