#!/bin/bash # example-cron-disk.sh # Exemple de script cron qui envoie un résumé d'espace disque vers ntfy-bridge. # À appeler depuis cron : 0 9 * * * /path/to/example-cron-disk.sh NTFY_BRIDGE_URL="${NTFY_BRIDGE_URL:-http://127.0.0.1:9090}" WEBHOOK_PATH="${WEBHOOK_PATH:-/webhooks/cron-disk}" # Collecter l'info disque DISK_INFO=$(df -h / /mnt/nfs /home 2>/dev/null | tail -n +2 | awk '{print " " $6 ": " $3 "/" $2 " (" $5 " used)"}') # Construire le message MESSAGE="💾 **Disk Usage Report** — $(date '+%Y-%m-%d %H:%M') ${DISK_INFO} Warnings (>80%): $(df -h / /mnt/nfs /home 2>/dev/null | awk 'NR>1 {gsub(/%/,"",$5); if ($5+0 > 80) print " ⚠️ " $6 " is at " $5 "%"}' || echo " ✅ All partitions under 80%")" # Envoyer vers ntfy-bridge curl -s -X POST \ -H "Content-Type: text/plain" \ -d "$MESSAGE" \ "${NTFY_BRIDGE_URL}${WEBHOOK_PATH}" > /dev/null echo "Disk report sent to ntfy-bridge"