83 lines
1.5 KiB
Markdown
83 lines
1.5 KiB
Markdown
# CheckStorage
|
||
|
||
Script de vérification de l’espace disque sur Ubuntu Server, avec notification Discord optionnelle.
|
||
|
||
## Fonctionnement
|
||
|
||
Le script :
|
||
|
||
1. charge `.env`
|
||
2. lit l’utilisation de la partition `/`
|
||
3. compare le taux d’occupation au seuil configuré
|
||
4. envoie une alerte Discord si le seuil est dépassé
|
||
|
||
<details>
|
||
<summary style="list-style: none; cursor: pointer;">
|
||
<strong>EggMaster</strong>
|
||
</summary>
|
||
|
||
<details>
|
||
<summary style="list-style: none; cursor: pointer;">Question 3</summary>
|
||
|
||
Quel operateur shell permet d'envoyer la sortie d'une commande vers la suivante ?
|
||
|
||
</details>
|
||
|
||
<details>
|
||
<summary style="list-style: none; cursor: pointer;">Indice commande 3</summary>
|
||
|
||
```text
|
||
|
|
||
```
|
||
|
||
</details>
|
||
|
||
<details>
|
||
<summary style="list-style: none; cursor: pointer;">Fragment 3</summary>
|
||
|
||
```text
|
||
b3llciB2b2ljaSB1biBsaWVuIG1hZ2lxdWUgZW
|
||
```
|
||
|
||
</details>
|
||
|
||
</details>
|
||
## Pré-requis
|
||
|
||
Installation recommandée sur Ubuntu Server :
|
||
|
||
```bash
|
||
sudo apt update
|
||
sudo apt install -y coreutils gawk jq curl
|
||
```
|
||
|
||
`jq` et `curl` ne sont nécessaires que si `DISCORD_WEBHOOK_URL` est renseigné.
|
||
|
||
## Configuration
|
||
|
||
```bash
|
||
cp .env.exemple .env
|
||
chmod 600 .env
|
||
```
|
||
|
||
Variables disponibles :
|
||
|
||
- `DISCORD_WEBHOOK_URL` : webhook Discord, optionnel
|
||
- `DISCORD_PING` : mention en cas d’alerte, optionnel, défaut `@here`
|
||
- `STORAGE_ALERT_LIMIT` : seuil d’alerte en pourcentage, défaut `70`
|
||
|
||
## Utilisation
|
||
|
||
```bash
|
||
chmod 700 check-storage.sh
|
||
./check-storage.sh
|
||
```
|
||
|
||
## Cron
|
||
|
||
Exemple quotidien à `07:50` :
|
||
|
||
```bash
|
||
50 7 * * * /chemin/vers/CheckStorage/check-storage.sh
|
||
```
|