From 9271b99ae5d0256981438a3276bdec8de814aed0 Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 11:35:28 +0100 Subject: [PATCH 01/10] fix : mis dans un dossier --- check_storage.sh => CheckStorage/check_storage.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename check_storage.sh => CheckStorage/check_storage.sh (100%) diff --git a/check_storage.sh b/CheckStorage/check_storage.sh similarity index 100% rename from check_storage.sh rename to CheckStorage/check_storage.sh From 0664831fe3ecc61a882e8c3257094f7766eb6dfe Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 11:43:20 +0100 Subject: [PATCH 02/10] Stop tracking .env --- .env | 0 .env.exemple | 1 + .gitignore | 0 3 files changed, 1 insertion(+) create mode 100644 .env create mode 100644 .env.exemple create mode 100644 .gitignore diff --git a/.env b/.env new file mode 100644 index 0000000..e69de29 diff --git a/.env.exemple b/.env.exemple new file mode 100644 index 0000000..20cbf10 --- /dev/null +++ b/.env.exemple @@ -0,0 +1 @@ +WEBHOOK_URL="https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyz" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 From 624658e3af0e41d5c7d0773a4b23b2b4cd69e03c Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 11:44:03 +0100 Subject: [PATCH 03/10] fix : variable environement --- .env.exemple | 2 +- .gitignore | 9 +++++++++ CheckStorage/check_storage.sh | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.env.exemple b/.env.exemple index 20cbf10..ee717ba 100644 --- a/.env.exemple +++ b/.env.exemple @@ -1 +1 @@ -WEBHOOK_URL="https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyz" \ No newline at end of file +WEBHOOK_URL="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index e69de29..afdbc42 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,9 @@ +# Secrets / environment +.env +.env.* +!.env.example +!.env.exemple + +# IDE / editor +.idea/ +.vscode/ \ No newline at end of file diff --git a/CheckStorage/check_storage.sh b/CheckStorage/check_storage.sh index 29d7685..e2d8013 100644 --- a/CheckStorage/check_storage.sh +++ b/CheckStorage/check_storage.sh @@ -1,6 +1,7 @@ #!/bin/bash limit=1 -WEBHOOK_URL="https://discord.com/api/webhooks/1479061246903845048/oInyHOf1l7t-jbu9c1lvQDBUxT7m96sUpoDak-V_wjR4IRFi2zz9prC20IKq6cLHF8FO" +# 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)) From 73fa0e445149e205afd3cf8242924f5e05e1c336 Mon Sep 17 00:00:00 2001 From: Kevin Boudet Date: Thu, 5 Mar 2026 10:44:32 +0000 Subject: [PATCH 04/10] Supprimer .env --- .env | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index e69de29..0000000 From 38f1aa530226c98e7456e9fa371b95cf35c8cb58 Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 11:45:34 +0100 Subject: [PATCH 05/10] fix : comment --- CheckStorage/check_storage.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CheckStorage/check_storage.sh b/CheckStorage/check_storage.sh index e2d8013..104445b 100644 --- a/CheckStorage/check_storage.sh +++ b/CheckStorage/check_storage.sh @@ -2,9 +2,13 @@ limit=1 # Mettre le lien de votre webhook Discord dans un .env WEBHOOK_URL=$(grep -E '^WEBHOOK_URL=' .env | cut -d '=' -f2-) + +# Récupérer l'utilisation du disque en pourcentage usage=$(df -h / | awk 'NR==2 {gsub(/%/,"",$5); print $5}') +# Calculer l'espace libre en pourcentage free=$((100 - usage)) +# Si l'utilisation dépasse la limite, envoyer une alerte sur Discord 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 \ @@ -12,6 +16,7 @@ if [ "$usage" -ge "$limit" ]; then -H "Content-Type: application/json; charset=utf-8" \ -d "{\"content\":\"$msgLimit\"}" \ "$WEBHOOK_URL" + # Log de l'alerte echo "ALERTE >> ${usage}% d'utilisation, check fait le $(date)" echo "------------------------------------------------------------" fi From b5d06e6a15825e3c371119626620a2ecd756f2ba Mon Sep 17 00:00:00 2001 From: Kevin Boudet Date: Thu, 5 Mar 2026 10:52:29 +0000 Subject: [PATCH 06/10] Actualiser .env.exemple --- .env.exemple | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.exemple b/.env.exemple index ee717ba..541796c 100644 --- a/.env.exemple +++ b/.env.exemple @@ -1 +1 @@ -WEBHOOK_URL="" \ No newline at end of file +WEBHOOK_URL= \ No newline at end of file From 62b4f37c5f40e065d8423e9cbb24ceacbf80bb1d Mon Sep 17 00:00:00 2001 From: Kevin Boudet Date: Thu, 5 Mar 2026 10:52:52 +0000 Subject: [PATCH 07/10] Actualiser CheckStorage/check_storage.sh --- CheckStorage/check_storage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CheckStorage/check_storage.sh b/CheckStorage/check_storage.sh index 104445b..4ec5f1e 100644 --- a/CheckStorage/check_storage.sh +++ b/CheckStorage/check_storage.sh @@ -1,5 +1,5 @@ #!/bin/bash -limit=1 +limit=70 # Mettre le lien de votre webhook Discord dans un .env WEBHOOK_URL=$(grep -E '^WEBHOOK_URL=' .env | cut -d '=' -f2-) From 2c7de73734b8018ec78be5da5c2f93bbd77c6bd7 Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 13:46:11 +0100 Subject: [PATCH 08/10] feat : changelog --- CheckStorage/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CheckStorage/README.md diff --git a/CheckStorage/README.md b/CheckStorage/README.md new file mode 100644 index 0000000..59f21e2 --- /dev/null +++ b/CheckStorage/README.md @@ -0,0 +1 @@ +# Scripts Serveur MALIO From 887a3c3b0520f06a354e76ab27f89993b20b2d02 Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 13:52:11 +0100 Subject: [PATCH 09/10] feat : changelog --- CheckStorage/README.md | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/CheckStorage/README.md b/CheckStorage/README.md index 59f21e2..dd5886b 100644 --- a/CheckStorage/README.md +++ b/CheckStorage/README.md @@ -1 +1,43 @@ -# Scripts Serveur MALIO +# Scripts de vérification de l'espace de stockage + +Ce projet contient des scripts pour vérifier l'espace de stockage + +## Préambule +Ce script est conçu pour vérifier l'espace de stockage disponible sur un serveur et envoyer une alerte +La vérification de l'espace de stockage ce fait sur la partition racine. +La limite d'alerte est fixée à 70% d'utilisation, mais vous pouvez ajuster cette valeur dans le script selon vos besoins. + +## Installation du script + +1. Clonez le dépôt GitHub : + ```bash + git clone https://gitea.malio.fr/MALIO-DEV/Scripts-Serveur.git + ``` + +2. Accédez au répertoire du projet : +3. ```bash + cd Scripts-Serveur/CheckStorage + ``` + +## Utilisation du script +1. Donnez les permissions d'exécution au script : + ```bash + chmod +x check_storage.sh + ``` +2. Exécutez le script pour vérifier l'espace de stockage : + ```bash + ./check_storage.sh + ``` + +## Initialisé un cron pour exécuter le script régulièrement +1. Ouvrez le crontab pour l'édition : + ```bash + crontab -e + ``` +2. Ajoutez la ligne suivante pour exécuter le script tous les jours à 7h50 du matin : + ```bash + 50 7 * * * /chemin/vers/le/script/check_storage.sh + ``` + +## Avertissement +Assurez-vous de remplacer `/chemin/vers/le/script/check_storage.sh` par le chemin réel où se trouve le script sur votre système. \ No newline at end of file From e28905657a0fd1ea148cdb7bc15a2e040d87026e Mon Sep 17 00:00:00 2001 From: Lethary Date: Thu, 5 Mar 2026 13:54:15 +0100 Subject: [PATCH 10/10] feat : changelog --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 59f21e2..b579fed 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ # Scripts Serveur MALIO + +Ce projet contient des scripts pour la gestion et la maintenance des serveurs de MALIO. + + +## Scripts disponibles +* [CheckStorage] : Script de vérification de l'espace de stockage \ No newline at end of file