10 Commits
3 changed files with 746 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
# Monitoring
---
## Sujet : Moniteur système basique
### Objectif
Écrire un script **bash** simple permettant d’afficher des informations essentielles sur l’état du système GNU/Linux.
---
## Énoncé
Vous devez écrire un script shell nommé `monitor.sh` affichant les informations suivantes :
- Utilisation du CPU (en %)C
- Espace disque (partition home `/home`)
- Nombre de processus actifs (pour tout le système)
L’affichage doit être clair et lisible, avec des unités adaptées.
---
### Commandes ou fichiers possibles
Vous pouvez utiliser soit les commandes système ou les fichiers /proc
- `top`, `free`, `df`, `ps`
- `/proc/cpuinfo`, `/proc/meminfo`
---
## Bonus (facultatif)
### Mode surveillance
Ajouter un mode optionnel :
```bash
./monitor.sh -w X
```
Le script se rafraîchit toutes les `X` secondes.
*Indications :* `while`, `sleep`, `clear`
---
## Évaluation
| Critère | Points |
|-------|--------|
| Fonctionnalité correcte | 10 |
| Lisibilité / commentaires | 10 |
| Bonus surveillance | +4 |
---
+580
View File
@@ -0,0 +1,580 @@
2026-04-03 09:10:30 - OK: CPU usage 12% within threshold (80%)
2026-04-03 09:28:05 - OK: CPU usage 19% within threshold (80%)
2026-04-03 09:31:08 - OK: CPU usage 24% within threshold (80%)
2026-04-03 09:32:03 - OK: CPU usage 21% within threshold (80%)
2026-04-03 09:34:19 - OK: CPU usage 12% within threshold (80%)
2026-04-03 09:39:21 - OK: CPU usage 29% within threshold (80%)
2026-04-03 09:39:48 - OK: CPU usage 12% within threshold (80%)
2026-04-03 09:43:29 - OK: CPU usage 21% within threshold (80%)
2026-04-03 09:44:03 - OK: CPU usage 13% within threshold (80%)
2026-04-03 09:52:13 - OK: CPU usage 12% within threshold (80%)
2026-04-03 10:59:14 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:01:10 - OK: CPU usage 28% within threshold (50%)
2026-04-03 11:02:03 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 14% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 10% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 14% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 11% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 13% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 25% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 10% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 10% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 9% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 11% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:55:45 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 13% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 13% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 14% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 10% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 9% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 13% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 23% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 26% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 23% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 23% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 14% within threshold (50%)
2026-04-03 11:56:21 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 25% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 11% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 13% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 11% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 9% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 11% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 10% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 11% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 34% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 13% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 12% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 23% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 25% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 25% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 24% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 22% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 14% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 23% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 19% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 20% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 15% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 14% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 16% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 17% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 18% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 21% within threshold (50%)
2026-04-03 11:57:22 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 9% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 26% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 9% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:01:11 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 25% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 25% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 25% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:42 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:01:48 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 24% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:03:38 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 24% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:04:50 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:05:35 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:05:57 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:05:57 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:05:57 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:05:57 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:09:20 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:10:55 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:12:04 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:13:16 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:14:00 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:14:35 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:14:35 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:14:35 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:14:35 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:14:42 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:14:42 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:14:42 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:14:42 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:14:42 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:14:42 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:16:13 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:16:29 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 9% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:19:05 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:19:52 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:19:52 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:19:52 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:19:52 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:19:52 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:20:14 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:20:14 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:23:14 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:25:31 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:25:44 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:25:49 - OK: CPU usage 22% within threshold (50%)
2026-04-03 12:27:46 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:28:07 - OK: CPU usage 10% within threshold (50%)
2026-04-03 12:28:14 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:28:19 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:29:58 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 24% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 20% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 23% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 21% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 11% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 13% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 14% within threshold (50%)
2026-04-03 12:30:08 - OK: CPU usage 12% within threshold (50%)
2026-04-03 12:30:58 - OK: CPU usage 18% within threshold (50%)
2026-04-03 12:30:58 - OK: CPU usage 15% within threshold (50%)
2026-04-03 12:30:58 - OK: CPU usage 19% within threshold (50%)
2026-04-03 12:30:58 - OK: CPU usage 16% within threshold (50%)
2026-04-03 12:30:58 - OK: CPU usage 17% within threshold (50%)
2026-04-03 12:30:58 - OK: CPU usage 15% within threshold (50%)
Executable
+108
View File
@@ -0,0 +1,108 @@
#!/bin/bash
# === Configuration ===
THRESHOLD=50 # CPU usage threshold (%)
LOG_FILE="/home/isen/isen2024/cpualert.log"
STATE_FILE="/home/isen/isen2024/cpualertstate" # Tracks alert state
HOSTNAME=$(hostname)
DATE=$(date '+%Y-%m-%d %H:%M:%S')
# === Functions ===
# Function to check required commands
check_dependencies() {
for cmd in top df ; do
if ! command -v "$cmd" &>/dev/null; then
echo "$DATE - ERROR: Required command '$cmd' not found." | tee -a "$LOG_FILE"
exit 1
fi
done
}
# Function to get average CPU usage across all cores
get_cpu_usage() {
# Extract CPU usage using top command
local usage
usage=$(top -bn1 | grep "Cpu(s)" | awk '{print 100 - $8}')
#Extrait la 8ème colonne ($8), qui correspond au pourcentage de temps CPU inactif (%id).
#Calcule l utilisation CPU en soustrayant ce pourcentage d'inactivité de 100 (exemple : si $8 vaut 85.3, alors 100 - 85.3 = 14.7).
#Le resultat est stocké dans la variable usage.
# Handle empty or invalid values
if [[ -z "$usage" || "$usage" == *"e+"* ]]; then
echo "0"
else
echo "${usage%.*}" # strip decimals
fi
}
#Fonction pour afficher l'espace disque de /home
espace_disque() {
pourcentage_disque=$( df -h /home | grep overlay | awk '{print $5}')
echo "Pourcentge de memoire utilise: ${pourcentage_disque}"
}
#Fonction pour afficher le nombre de processus:
nb_proc() {
nb_proc=$(ps aux --no-header | wc -l)
echo "Nombres de precessus en cours sur la machine: ${nb_proc}"
}
# function to log messages in logfile
log_message() {
echo "$DATE - $1" | tee -a "$LOG_FILE"
}
#fonction pour afficher le résultat dans le terminal
prompt_message() {
echo "$1"
}
# === Main Function ===
monitoring() {
clear
check_dependencies
CPU_USAGE=$(get_cpu_usage)
CPU_INT=${CPU_USAGE%.*}
if [[ ! "$CPU_INT" =~ ^[0-9]+$ ]]; then
log_message "ERROR: Invalid CPU usage value '$CPU_INT'"
prompt_message "ERROR: Invalid CPU usage value '$CPU_INT'"
exit 1
fi
if (( CPU_INT > THRESHOLD )); then
# CPU high
if [[ ! -f "$STATE_FILE" ]]; then
log_message "ALERT: CPU usage ${CPU_INT}% > ${THRESHOLD}%. "
prompt_message "ALERTE: CPU usage ${CPU_INT}% > ${THRESHOLD}"
else
log_message "ALERT: CPU usage ${CPU_INT}% > ${THRESHOLD}%."
prompt_message "ALERT: CPU usage ${CPU_INT}% > ${THRESHOLD}%."
fi
else
# CPU normal
if [[ -f "$STATE_FILE" ]]; then
log_message "RECOVERY: CPU usage ${CPU_INT}% < ${THRESHOLD}%."
prompt_message "RECOVERY: CPU usage ${CPU_INT}% < ${THRESHOLD}%."
rm -f "$STATE_FILE"
else
log_message "OK: CPU usage ${CPU_INT}% within threshold (${THRESHOLD}%)"
prompt_message " OK: CPU usage ${CPU_INT}% within threshold (${THRESHOLD}%)"
fi
fi
espace_disque
nb_proc
}
main() {
if [ "$#" -ne 2 ] || [ "$1" != "-w" ]; then
echo "Erreur : Utilisation incorrecte."
echo "Usage: $0 -w X (X = intervalle en secondes)"
sleep 2
monitoring
exit 1
fi
# Récupération de l'intervalle
local sleeptime=$2
echo "lancement du monito avec un rafraichissement de $sleeptime secondes"
while true; do
monitoring
sleep "$sleeptime"
done
}
main "$1" "$2"