Add memory usage

This commit is contained in:
Skylar Ittner 2025-08-31 16:20:40 -06:00
parent 346a97d203
commit 881f68c2d2

View File

@ -1,7 +1,8 @@
API_URL="https://status.netsyms.net/api/push/" API_URL="https://status.netsyms.net/api/push/"
PUSH_KEY="" PUSH_KEY=""
DISK_FULL_ALERT_PERCENT_THRESHOLD=85 DISK_FULL_ALERT_PERCENT_THRESHOLD=85
CPU_USAGE_PERCENT_THRESHOLD=50 CPU_USAGE_PERCENT_THRESHOLD=60
MEM_USAGE_PERCENT_THRESHOLD=80
# ZFS health # ZFS health
echo -n "Checking ZFS health: " echo -n "Checking ZFS health: "
@ -39,6 +40,15 @@ if [[ $CPU_PERCENT > $CPU_USAGE_PERCENT_THRESHOLD ]]; then
fi fi
echo "$CPU_STATUS" echo "$CPU_STATUS"
# Memory usage percentage
echo -n "Checking memory usage: "
MEM_STATUS="OK"
MEM_PCT=$(free -m | awk 'NR==2{ print $3*100/$2 }')
if [[ $MEM_PCT > $MEM_USAGE_PERCENT_THRESHOLD ]]; then
MEM_STATUS="$MEM_PCT% > $MEM_USAGE_PERCENT_THRESHOLD%"
fi
# #
# Put it all together # Put it all together
# #
@ -56,6 +66,10 @@ if [[ $CPU_STATUS != "OK" ]]; then
IS_OK=0 IS_OK=0
ERROR_MESSAGES+=("CPU usage alert: $CPU_STATUS") ERROR_MESSAGES+=("CPU usage alert: $CPU_STATUS")
fi fi
if [[ $MEM_STATUS != "OK" ]]; then
IS_OK=0
ERROR_MESSAGES+=("Memory usage alert: $MEM_STATUS")
fi
echo -n "Sending status: " echo -n "Sending status: "