Merge pull request 'feat : ajout du script pour check le stockage et envoyer un message sur discord' (#1) from feat/372-script-check-stockage into main
Reviewed-on: MALIO-DEV/Scripts-Serveur#1
This commit was merged in pull request #1.
This commit is contained in:
16
check_storage.sh
Normal file
16
check_storage.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
limit=1
|
||||||
|
WEBHOOK_URL="https://discord.com/api/webhooks/1479039017264746536/qwdnBsW1yPdtzSTirYs6GORmtppfOObNnEHTVlMoADrAIxTY2ja1uslSBvRyXK4XJCex"
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user