Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0427bd202f | ||
|
|
3245c3d044 | ||
|
|
4ed923b960 | ||
|
|
7dc5f55f16 | ||
|
|
1fd43d1b0e | ||
|
|
225cff0d35 | ||
|
|
841007ef76 | ||
|
|
3698339c2f | ||
|
|
7a8ae99069 | ||
|
|
50da9de9db | ||
|
|
a071b05552 | ||
|
|
11f956b755 | ||
|
|
cd0b26a5b9 | ||
|
|
4037244be6 | ||
|
|
74da2c244d | ||
|
|
880ae493ad | ||
|
|
418120538f | ||
|
|
7e7ff0d27e | ||
|
|
f86adf8006 | ||
|
|
c3ca691c8f | ||
|
|
85d296f8da |
@@ -1,58 +0,0 @@
|
||||
# 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 |
|
||||
|
||||
---
|
||||
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#Utilisation du CPU
|
||||
UsCPU(){
|
||||
top -bn1 | grep Cpu | awk '{print 100-$8}'
|
||||
}
|
||||
|
||||
#Espace disponible dans /home
|
||||
SpaceDispo(){
|
||||
df -h /home | grep overlay | awk '{print $4}'
|
||||
}
|
||||
|
||||
#Nombre de processus actifs
|
||||
Procactif(){
|
||||
ps aux --no-header | wc -l
|
||||
}
|
||||
|
||||
#Affichage si -w X
|
||||
|
||||
Affichage(){
|
||||
echo "
|
||||
____________________________________________
|
||||
Monitoring du PC :
|
||||
____________________________________________
|
||||
L'usage du CPU est : $1
|
||||
l'espace disponible dans /home est: $2
|
||||
Il y a $3 processus actif(s)
|
||||
____________________________________________
|
||||
"
|
||||
}
|
||||
|
||||
if [ "$#" -ne 0 ] && [ "$#" -ne 2 ];
|
||||
then
|
||||
echo "Erreur : Veuillez specifier vos parametres (0 ou2)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $1 == "-w" ]]
|
||||
then
|
||||
# Rafraichir toutes les $2 secondes
|
||||
while [[ True ]]
|
||||
do
|
||||
#Recupere les variables (changent a chaque iteration)
|
||||
proc=$(UsCPU)
|
||||
space=$(SpaceDispo)
|
||||
nbrproc=$(Procactif)
|
||||
# Raffraichit toutes les $2 secondes
|
||||
Affichage $proc $space $nbrproc
|
||||
sleep $2
|
||||
clear
|
||||
done
|
||||
else
|
||||
# Affichage simple
|
||||
proc=$(UsCPU)
|
||||
space=$(SpaceDispo)
|
||||
nbrproc=$(Procactif)
|
||||
Affichage $proc $space $nbrproc
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user