Last active
December 11, 2022 12:15
-
-
Save RealLukeManning/3b87ed1b91aba5cf5d338d972580e121 to your computer and use it in GitHub Desktop.
A small bash script for sending myself notifications from unRAID
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
#!/bin/bash | |
TOKEN=XXX | |
CHAT_ID=XXX | |
URL="https://api.telegram.org/bot$TOKEN/sendMessage" | |
LIMIT=95 | |
CACHE_LIMIT=60 | |
#Checks how much space% is consumed on the array | |
ARRAY_USED_PERCENT=`df -h /mnt/user | awk '{print $5}' | sed -ne 2p | cut -d'%' -f1` | |
#Checks how much available space there is in GB | |
ARRAY_AVAIL_SPACE=`df -h /mnt/user | awk '{print $4}' | sed -ne 2p` | |
#Checks how much space% is consumed on the cache drive | |
CACHE_USED=`df -h /mnt/cache | awk '{print $5}' | sed -ne 2p | cut -d'%' -f1` | |
#Checks how much available space there is in GB | |
CACHE_AVAIL_SPACE=`df -h /mnt/cache | awk '{print $4}' | sed -ne 2p` | |
if [ $ARRAY_USED_PERCENT -ge $LIMIT ] | |
then | |
MESSAGE="WARNING: Free Array Space is at `expr 100 - $ARRAY_USED_PERCENT`%. There is $ARRAY_AVAIL_SPACE available." | |
curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MESSAGE" | |
fi | |
if [ $CACHE_USED -ge $CACHE_LIMIT ] | |
then | |
MESSAGE="WARNING: Free Cache space has fallen below `expr 100 - $CACHE_USED`%. There is $CACHE_AVAIL_SPACE available." | |
curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MESSAGE" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment