script
This commit is contained in:
201
IMPLEMENTATION_STATUS.md
Normal file
201
IMPLEMENTATION_STATUS.md
Normal file
@@ -0,0 +1,201 @@
|
||||
# État d'Implémentation - Linux BenchTools
|
||||
|
||||
## ✅ Complété
|
||||
|
||||
### 1. Script de Collecte Local (`script_test.sh`)
|
||||
- ✅ Collecte complète des informations hardware
|
||||
- ✅ Données SMART des disques (santé + vieillissement)
|
||||
- ✅ Statistiques RAM détaillées (used, free, shared)
|
||||
- ✅ Wake-on-LAN pour cartes ethernet
|
||||
- ✅ Benchmarks (CPU, RAM, Disk, Network via iperf3)
|
||||
- ✅ Génération de `result.json` complet
|
||||
- ✅ PATH fix pour `/usr/sbin`
|
||||
|
||||
### 2. Docker Infrastructure
|
||||
- ✅ Service backend (FastAPI)
|
||||
- ✅ Service frontend (Nginx)
|
||||
- ✅ Service iperf3 (port 5201)
|
||||
|
||||
### 3. Modèles de Base de Données
|
||||
- ✅ Modèle `HardwareSnapshot` mis à jour (RAM used/free/shared)
|
||||
- ✅ Nouveau modèle `DiskSMART` pour données de vieillissement
|
||||
- ✅ Relations entre modèles configurées
|
||||
|
||||
### 4. Script Client (`scripts/bench.sh`)
|
||||
- ✅ Wrapper pour `script_test.sh`
|
||||
- ✅ Parsing d'arguments (--server, --token, --iperf-server)
|
||||
- ✅ Vérification et installation des dépendances
|
||||
- ✅ Envoi POST des résultats au serveur
|
||||
|
||||
## 🚧 En Cours / À Faire
|
||||
|
||||
### 5. Schémas Pydantic (Backend)
|
||||
**Problème**: Les schémas actuels ne correspondent pas à la structure de `result.json`
|
||||
|
||||
#### Format actuel attendu par l'API:
|
||||
```json
|
||||
{
|
||||
"device_identifier": "hostname",
|
||||
"bench_script_version": "1.0.0",
|
||||
"hardware": {
|
||||
"cpu": { "vendor": "...", "model": "..." },
|
||||
"ram": { "total_mb": 8000, "layout": [...] },
|
||||
"storage": { "devices": [...], "partitions": [...] },
|
||||
...
|
||||
},
|
||||
"results": {
|
||||
"cpu": { "score": 50 },
|
||||
"memory": { "score": 60 },
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Format généré par `result.json`:
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"script_version": "1.0.0",
|
||||
"timestamp": "2025-12-07T19:47:34Z"
|
||||
},
|
||||
"system": {
|
||||
"hostname": "lenovo-bureau",
|
||||
"os": { "name": "debian", ... }
|
||||
},
|
||||
"hardware": {
|
||||
"cpu": { "vendor": "...", "model": "...", "flags": [...] },
|
||||
"ram": {
|
||||
"total_mb": 7771,
|
||||
"used_mb": 6123, // NOUVEAU
|
||||
"free_mb": 923, // NOUVEAU
|
||||
"shared_mb": 760, // NOUVEAU
|
||||
"layout": [...]
|
||||
},
|
||||
"storage": [ // Format différent: array au lieu d'objet
|
||||
{
|
||||
"device": "sda",
|
||||
"model": "...",
|
||||
"smart": { // NOUVEAU
|
||||
"health_status": "PASSED",
|
||||
"power_on_hours": 7101,
|
||||
...
|
||||
}
|
||||
}
|
||||
],
|
||||
"network": [ // Format différent: array au lieu d'objet
|
||||
{
|
||||
"name": "eno1",
|
||||
"wake_on_lan": true // NOUVEAU
|
||||
}
|
||||
]
|
||||
},
|
||||
"benchmarks": { // "results" dans l'API
|
||||
"cpu": { "events_per_sec": 1206, "score": 12.06 },
|
||||
"global_score": 10.85
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Actions Requises:
|
||||
|
||||
#### Option A: Modifier les Schémas Pydantic (Recommandé)
|
||||
- [ ] Mettre à jour `RAMInfo` pour ajouter `used_mb`, `free_mb`, `shared_mb`
|
||||
- [ ] Créer `SMARTData` schema pour les données SMART
|
||||
- [ ] Mettre à jour `StorageDevice` pour inclure `smart: SMARTData`
|
||||
- [ ] Mettre à jour `NetworkInterface` pour ajouter `wake_on_lan`, `ip_address`
|
||||
- [ ] Créer un mapper qui convertit `result.json` → format API attendu
|
||||
- `metadata.script_version` → `bench_script_version`
|
||||
- `system.hostname` → `device_identifier`
|
||||
- `hardware.storage[]` → `hardware.storage.devices[]`
|
||||
- `hardware.network[]` → `hardware.network.interfaces[]`
|
||||
- `benchmarks` → `results`
|
||||
|
||||
#### Option B: Adapter le script client
|
||||
- [ ] Modifier `script_test.sh` pour générer le format attendu par l'API
|
||||
- ⚠️ Moins flexible, car le format local serait différent du format serveur
|
||||
|
||||
### 6. API Backend (`backend/app/api/benchmark.py`)
|
||||
- [ ] Adapter le parsing pour les nouvelles données
|
||||
- [ ] Sauvegarder les données SMART dans la table `disk_smart_data`
|
||||
- [ ] Gérer les nouveaux champs RAM (used/free/shared)
|
||||
- [ ] Gérer wake_on_lan pour les interfaces réseau
|
||||
|
||||
### 7. Migration Alembic
|
||||
- [ ] Créer migration pour:
|
||||
- `hardware_snapshots.ram_used_mb`
|
||||
- `hardware_snapshots.ram_free_mb`
|
||||
- `hardware_snapshots.ram_shared_mb`
|
||||
- Nouvelle table `disk_smart_data`
|
||||
|
||||
### 8. Frontend
|
||||
- [ ] Afficher les données SMART (santé des disques)
|
||||
- [ ] Afficher l'utilisation RAM détaillée
|
||||
- [ ] Afficher Wake-on-LAN status
|
||||
- [ ] Graphiques d'évolution SMART (power_on_hours, température)
|
||||
|
||||
### 9. Tests
|
||||
- [ ] Tester le flux complet local → serveur
|
||||
- [ ] Vérifier que toutes les données sont bien sauvegardées
|
||||
- [ ] Tester avec plusieurs machines
|
||||
|
||||
## 🎯 Prochaines Étapes Recommandées
|
||||
|
||||
1. **Créer un mapper `result.json` → API format**
|
||||
- Fichier: `backend/app/utils/result_mapper.py`
|
||||
- Fonction: `map_result_json_to_api_payload(result_json) -> BenchmarkPayload`
|
||||
|
||||
2. **Mettre à jour les schémas Pydantic**
|
||||
- Ajouter les nouveaux champs dans `schemas/hardware.py`
|
||||
|
||||
3. **Adapter l'API `benchmark.py`**
|
||||
- Utiliser le mapper
|
||||
- Sauvegarder les données SMART
|
||||
|
||||
4. **Créer la migration Alembic**
|
||||
```bash
|
||||
cd backend
|
||||
alembic revision --autogenerate -m "Add RAM stats and SMART data"
|
||||
alembic upgrade head
|
||||
```
|
||||
|
||||
5. **Tester le flux complet**
|
||||
```bash
|
||||
# 1. Démarrer le serveur
|
||||
docker-compose up -d
|
||||
|
||||
# 2. Exécuter le benchmark
|
||||
sudo bash scripts/bench.sh --server http://10.0.1.97:8007 --token YOUR_TOKEN
|
||||
|
||||
# 3. Vérifier dans la base de données
|
||||
sqlite3 backend/data/data.db "SELECT * FROM disk_smart_data LIMIT 5;"
|
||||
```
|
||||
|
||||
## 📊 Structure de `result.json` Complète
|
||||
|
||||
Voir le fichier [result.json](result.json) pour un exemple réel complet.
|
||||
|
||||
### Nouvelles Données vs Ancien Format
|
||||
|
||||
| Donnée | Ancien | Nouveau | Location |
|
||||
|--------|--------|---------|----------|
|
||||
| RAM utilisée | ❌ | ✅ `ram.used_mb` | `hardware.ram.used_mb` |
|
||||
| RAM libre | ❌ | ✅ `ram.free_mb` | `hardware.ram.free_mb` |
|
||||
| RAM partagée | ❌ | ✅ `ram.shared_mb` | `hardware.ram.shared_mb` |
|
||||
| SMART santé | ❌ | ✅ `smart.health_status` | `hardware.storage[].smart.health_status` |
|
||||
| SMART heures | ❌ | ✅ `smart.power_on_hours` | `hardware.storage[].smart.power_on_hours` |
|
||||
| SMART secteurs | ❌ | ✅ `smart.reallocated_sectors` | `hardware.storage[].smart.reallocated_sectors` |
|
||||
| Wake-on-LAN | ❌ | ✅ `wake_on_lan` | `hardware.network[].wake_on_lan` |
|
||||
| Network ping | ❌ | ✅ `ping_ms` | `benchmarks.network.ping_ms` |
|
||||
| IP address | ❌ | ✅ `ip_address` | `hardware.network[].ip_address` |
|
||||
|
||||
## 📝 Notes de Migration
|
||||
|
||||
### Base de Données
|
||||
- Nouvelle table: `disk_smart_data`
|
||||
- Champs ajoutés à `hardware_snapshots`: `ram_used_mb`, `ram_free_mb`, `ram_shared_mb`
|
||||
- Relations: `HardwareSnapshot` ← (1:N) → `DiskSMART`
|
||||
|
||||
### Compatibilité Ascendante
|
||||
- Les anciens benchmarks sans ces données afficheront `null`
|
||||
- Le système reste compatible avec les scripts clients plus anciens
|
||||
|
||||
Reference in New Issue
Block a user