Add inode health check

This commit is contained in:
Skylar Ittner 2025-10-24 11:16:16 -06:00
parent 0b100a136a
commit 9cd38574d6

View File

@ -10,6 +10,7 @@ PUSH_KEY="" # The random code in the URL generated by Uptime Kuma
GRAPH="CPU" # Which stat is graphed in Uptime Kuma. Can set to "RAM" for memory usage or to "" to disable. GRAPH="CPU" # Which stat is graphed in Uptime Kuma. Can set to "RAM" for memory usage or to "" to disable.
ENABLE_ZFS_MONITOR=1 # Set to 0 if you aren't using ZFS ENABLE_ZFS_MONITOR=1 # Set to 0 if you aren't using ZFS
DISK_FULL_ALERT_PERCENT_THRESHOLD=85 # Alerts if any filesystem is fuller than this DISK_FULL_ALERT_PERCENT_THRESHOLD=85 # Alerts if any filesystem is fuller than this
DISK_INODE_USAGE_ALERT_PERCENT_THRESHOLD=70 # Alerts if any filesystem is running low on free inodes
CPU_USAGE_PERCENT_THRESHOLD=60 # Alerts if CPU usage averages greater than this across 5 minutes CPU_USAGE_PERCENT_THRESHOLD=60 # Alerts if CPU usage averages greater than this across 5 minutes
MEM_USAGE_PERCENT_THRESHOLD=80 # Alerts if RAM usage rises over this percentage, ZFS ARC counts as used MEM_USAGE_PERCENT_THRESHOLD=80 # Alerts if RAM usage rises over this percentage, ZFS ARC counts as used
@ -22,7 +23,7 @@ if [[ $ENABLE_ZFS_MONITOR == 1 ]]; then
fi fi
# Disk usage # Disk usage
echo -n "Checking disk usage: " echo -n "Checking disk space usage: "
DISKS_STATUS="OK" DISKS_STATUS="OK"
USAGES=() USAGES=()
while read -r output; while read -r output;
@ -30,7 +31,7 @@ do
partition=$(echo "$output" | awk '{ print $2 }') partition=$(echo "$output" | awk '{ print $2 }')
percent=$(echo "$output" | awk '{ print $1 }' | cut -d'%' -f1) percent=$(echo "$output" | awk '{ print $1 }' | cut -d'%' -f1)
if [ $percent -ge $DISK_FULL_ALERT_PERCENT_THRESHOLD ]; then if [ $percent -ge $DISK_FULL_ALERT_PERCENT_THRESHOLD ]; then
USAGES+=("$partition: $percent% > $DISK_FULL_ALERT_PERCENT_THRESHOLD%") USAGES+=("$partition space used: $percent% > $DISK_FULL_ALERT_PERCENT_THRESHOLD%")
DISKS_STATUS="NOTOK" DISKS_STATUS="NOTOK"
fi fi
done <<< $(df | grep -vE "^Filesystem|tmpfs|cdrom|/dev/loop" | awk '{ print $5 " " $1 }') done <<< $(df | grep -vE "^Filesystem|tmpfs|cdrom|/dev/loop" | awk '{ print $5 " " $1 }')
@ -40,6 +41,27 @@ if [[ "$DISKS_STATUS" != "OK" ]]; then
fi fi
echo "$DISKS_STATUS" echo "$DISKS_STATUS"
# Inode usage
echo -n "Checking disk inode usage: "
DISK_INODE_STATUS="OK"
USAGES=()
while read -r output;
do
partition=$(echo "$output" | awk '{ print $2 }')
percent=$(echo "$output" | awk '{ print $1 }' | cut -d'%' -f1)
if [ $percent != '-' ]; then # Percent will be a - if the filesystem doesn't support this check
if [ $percent -gt $DISK_INODE_USAGE_ALERT_PERCENT_THRESHOLD ]; then
USAGES+=("$partition inodes used: $percent% > $DISK_INODE_USAGE_ALERT_PERCENT_THRESHOLD%")
DISK_INODE_STATUS="NOTOK"
fi
fi
done <<< $(df -i | grep -vE "^Filesystem|tmpfs|cdrom|/dev/loop" | awk '{ print $5 " " $1 }')
USAGETEXT=$(IFS=","; echo "${USAGES[*]}")
if [[ "$DISK_INODE_STATUS" != "OK" ]]; then
DISK_INODE_STATUS="$USAGETEXT"
fi
echo "$DISK_INODE_STATUS"
# CPU usage percentage # CPU usage percentage
# Calculated from system load, average over past 5 minutes # Calculated from system load, average over past 5 minutes
echo -n "Checking CPU load: " echo -n "Checking CPU load: "