#!/bin/bash limit=70 WEBHOOK_URL=$(grep -E '^WEBHOOK_URL=' .env | cut -d '=' -f2-) read -r total_bytes used_bytes avail_bytes usage <<<"$(df -B1 / | awk 'NR==2 {gsub(/%/,"",$5); print $2, $3, $4, $5}')" free=$((100 - usage)) used_gb=$(awk -v b="$used_bytes" 'BEGIN {printf "%.2f", b/1024/1024/1024}') total_gb=$(awk -v b="$total_bytes" 'BEGIN {printf "%.2f", b/1024/1024/1024}') avail_gb=$(awk -v b="$avail_bytes" 'BEGIN {printf "%.2f", b/1024/1024/1024}') if [ "$usage" -ge "$limit" ]; then msgLimit="@here\n**CHECK STOCKAGE :red_circle:**\nLimite autorisé : ${limit}%\nUtilisation actuelle: ${usage}%\nEspace restant: ${free}%\nUtilise / total: ${used_gb} GB / ${total_gb} GB\nDisponible: ${avail_gb} GB\nHeure: $(date)" curl -X POST \ -H "Accept: application/json" \ -H "Content-Type: application/json; charset=utf-8" \ -d "{\"content\":\"$msgLimit\"}" \ "$WEBHOOK_URL" fi echo "Espace disponible : ${avail_gb} GB" echo "Espace utilise / espace total : ${used_gb} GB / ${total_gb} GB" echo "Name: ${HOSTNAME}"