#!/bin/bash # Check network storage mounts (NFS/CIFS) set -euo pipefail SEND_NTFY="/usr/local/bin/send-ntfy.sh" # Network mounts to check MOUNTS=( "/mnt/pve/Fred:NFS Fred (Backups)" "/mnt/pve/iMacHDD:CIFS iMac" ) for mount_config in "${MOUNTS[@]}"; do IFS=':' read -r MOUNT_PATH MOUNT_NAME <<< "$mount_config" # Check if mount point exists and is mounted if ! mountpoint -q "$MOUNT_PATH" 2>/dev/null; then $SEND_NTFY critical "Network Storage Down" "🔴 CRITICAL: $MOUNT_NAME not mounted at $MOUNT_PATH!" "skull,error,cd" continue fi # Check if accessible (with timeout) if ! timeout 5 ls "$MOUNT_PATH" >/dev/null 2>&1; then $SEND_NTFY critical "Network Storage Stale" "🔴 CRITICAL: $MOUNT_NAME is STALE/FROZEN at $MOUNT_PATH (timeout)" "skull,error,cd" continue fi # Check disk usage DISK_INFO=$(df -h "$MOUNT_PATH" 2>/dev/null | tail -1) USAGE=$(echo "$DISK_INFO" | awk '{print $5}' | sed 's/%//') USED=$(echo "$DISK_INFO" | awk '{print $3}') TOTAL=$(echo "$DISK_INFO" | awk '{print $2}') FREE=$(echo "$DISK_INFO" | awk '{print $4}') if [ "$USAGE" -gt 90 ]; then $SEND_NTFY critical "Network Storage Full" "🔴 CRITICAL: $MOUNT_NAME at ${USAGE}%\nUsed: $USED/$TOTAL, Free: $FREE" "cd,skull" elif [ "$USAGE" -gt 80 ]; then $SEND_NTFY warning "Network Storage High" "🟡 WARNING: $MOUNT_NAME at ${USAGE}%\nUsed: $USED/$TOTAL, Free: $FREE" "cd,warning" fi logger -t network-storage-monitor "$MOUNT_NAME: ${USAGE}% used" done