diff --git a/uptimekuma.sh b/uptimekuma.sh index 557e9ea..6abab3a 100644 --- a/uptimekuma.sh +++ b/uptimekuma.sh @@ -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. 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_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 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 # Disk usage -echo -n "Checking disk usage: " +echo -n "Checking disk space usage: " DISKS_STATUS="OK" USAGES=() while read -r output; @@ -30,7 +31,7 @@ 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% > $DISK_FULL_ALERT_PERCENT_THRESHOLD%") + USAGES+=("$partition space used: $percent% > $DISK_FULL_ALERT_PERCENT_THRESHOLD%") DISKS_STATUS="NOTOK" fi done <<< $(df | grep -vE "^Filesystem|tmpfs|cdrom|/dev/loop" | awk '{ print $5 " " $1 }') @@ -40,6 +41,27 @@ if [[ "$DISKS_STATUS" != "OK" ]]; then fi 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 # Calculated from system load, average over past 5 minutes echo -n "Checking CPU load: "