fix : changelog plus readme a jour
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
|
||||
###############################################################################
|
||||
# CHARGEMENT DU .env
|
||||
@@ -22,8 +23,34 @@ set +a
|
||||
# CONFIGURATION
|
||||
###############################################################################
|
||||
|
||||
require_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1 || {
|
||||
echo "ERROR: commande requise absente : $1" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Limite maximale d'utilisation du disque en pourcentage
|
||||
limit=70
|
||||
limit="${STORAGE_ALERT_LIMIT:-70}"
|
||||
DISCORD_PING="${DISCORD_PING:-@here}"
|
||||
|
||||
[[ "$limit" =~ ^[0-9]+$ ]] || {
|
||||
echo "ERROR: STORAGE_ALERT_LIMIT invalide" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
(( limit >= 1 && limit <= 99 )) || {
|
||||
echo "ERROR: STORAGE_ALERT_LIMIT doit être compris entre 1 et 99" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
require_cmd df
|
||||
require_cmd awk
|
||||
|
||||
if [[ -n "${DISCORD_WEBHOOK_URL:-}" ]]; then
|
||||
require_cmd jq
|
||||
require_cmd curl
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# RÉCUPÉRATION DES INFORMATIONS DISQUE
|
||||
@@ -48,15 +75,17 @@ 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)"
|
||||
msgLimit="${DISCORD_PING}\n**CHECK STOCKAGE :red_circle:**\nLimite autorisée : ${limit}%\nUtilisation actuelle : ${usage}%\nEspace restant : ${free}%\nUtilisé / total : ${used_gb} GB / ${total_gb} GB\nDisponible : ${avail_gb} GB\nHeure : $(date)"
|
||||
|
||||
payload="$(jq -n --arg content "$msgLimit" '{content: $content}')"
|
||||
if [[ -n "${DISCORD_WEBHOOK_URL:-}" ]]; then
|
||||
payload="$(jq -n --arg content "$msgLimit" '{content: $content}')"
|
||||
|
||||
curl -X POST \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json; charset=utf-8" \
|
||||
-d "$payload" \
|
||||
"$DISCORD_WEBHOOK_URL"
|
||||
curl -fsS \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json; charset=utf-8" \
|
||||
-d "$payload" \
|
||||
"$DISCORD_WEBHOOK_URL" >/dev/null || true
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user