Files
Malio-ops/CheckStorage/check_storage.sh
2026-03-05 11:44:03 +01:00

18 lines
719 B
Bash

#!/bin/bash
limit=1
# Mettre le lien de votre webhook Discord dans un .env
WEBHOOK_URL=$(grep -E '^WEBHOOK_URL=' .env | cut -d '=' -f2-)
usage=$(df -h / | awk 'NR==2 {gsub(/%/,"",$5); print $5}')
free=$((100 - usage))
if [ "$usage" -ge "$limit" ]; then
msgLimit="@here\n**CHECK STOCKAGE :red_circle:**\nLimite autorisé : ${limit}% \nUtilisation actuelle: ${usage}%\nEspace restant: ${free}%\nHeure: $(date)"
curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json; charset=utf-8" \
-d "{\"content\":\"$msgLimit\"}" \
"$WEBHOOK_URL"
echo "ALERTE >> ${usage}% d'utilisation, check fait le $(date)"
echo "------------------------------------------------------------"
fi