feat(status-monitor): Add complete status monitor code with git workflow
- Add VERSION file (v1.1.0) - Add README.md with complete git workflow documentation - Add deploy.sh (corrected version) - Add status-monitor.service for systemd - Status monitor app.py already exists in repo Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -0,0 +1,310 @@
|
||||
# Status Monitor - Homelab
|
||||
|
||||
**Application de monitoring des services Homelab**
|
||||
**Version** : 1.1.0
|
||||
**Auteur** : Mistral Vibe
|
||||
**Dernière mise à jour** : 19/07/2026
|
||||
|
||||
---
|
||||
|
||||
## 📋 Description
|
||||
|
||||
Application Python de monitoring des services Homelab. Elle vérifie régulièrement l'état (online/offline) de tous les services configurés et affiche un tableau de bord web en temps réel.
|
||||
|
||||
**Fonctionnalités** :
|
||||
- Vérification SSH, HTTP, HTTPS
|
||||
- Interface web responsive avec rafraîchissement automatique
|
||||
- Historique des changements de statut
|
||||
- Support des certificats SSL auto-signés (mode insecure)
|
||||
- Tableau de bord avec statistiques globales
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
```
|
||||
Internet → Traefik (CT200) → status.peis.fr
|
||||
↓
|
||||
CT201 (192.168.0.201:80)
|
||||
↓
|
||||
Status Monitor (Python HTTP Server)
|
||||
↓
|
||||
Vérifie tous les services configurés
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Déploiement
|
||||
|
||||
### Pré-requis
|
||||
- Python 3.x
|
||||
- Accès réseau à tous les services à surveiller
|
||||
- Port 80 disponible sur CT201
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
# Sur CT201 (192.168.0.201)
|
||||
apt update && apt install -y python3 python3-pip
|
||||
|
||||
# Créer le dossier
|
||||
mkdir -p /opt/status-monitor
|
||||
cd /opt/status-monitor
|
||||
|
||||
# Copier les fichiers depuis ce dépôt
|
||||
# (voir section Workflow Git ci-dessous)
|
||||
|
||||
# Installer le service systemd
|
||||
cp status-monitor.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable status-monitor
|
||||
systemctl start status-monitor
|
||||
|
||||
# Vérifier
|
||||
systemctl status status-monitor
|
||||
curl http://localhost
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Workflow Git (Processus Standard)
|
||||
|
||||
### Structure dans le dépôt
|
||||
```
|
||||
homelab-config/
|
||||
└── status-monitor/
|
||||
├── app.py # Application principale
|
||||
├── deploy.sh # Script de déploiement
|
||||
├── status-monitor.service # Service systemd
|
||||
├── VERSION # Version actuelle
|
||||
└── README.md # Ce fichier
|
||||
```
|
||||
|
||||
### 1. Développer / Modifier le code
|
||||
|
||||
```bash
|
||||
# Sur ta machine de développement (Windows)
|
||||
# Modifier les fichiers dans : C:\Users\theo\.vibe\Proxmox\inventair\status-monitor\
|
||||
|
||||
# Exemple : Modifier app.py
|
||||
nano C:\Users\theo\.vibe\Proxmox\inventair\status-monitor\app.py
|
||||
```
|
||||
|
||||
### 2. Pousser vers Git (via CT200)
|
||||
|
||||
```bash
|
||||
# Copier les fichiers modifiés vers CT200
|
||||
scp -i C:\Users\theo\.ssh\id_ed25519 app.py root@192.168.0.100:/opt/git-repos/homelab-config/status-monitor/
|
||||
|
||||
# Sur CT200 :
|
||||
ssh -i C:\Users\theo\.ssh\id_ed25519 root@192.168.0.100
|
||||
cd /opt/git-repos/homelab-config
|
||||
|
||||
# Vérifier les changements
|
||||
git status
|
||||
git diff status-monitor/
|
||||
|
||||
# Ajouter, commiter, pousser
|
||||
git add status-monitor/
|
||||
git commit -m "Update Status Monitor - <description des changements>
|
||||
|
||||
Generated by Mistral Vibe.
|
||||
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
### 3. Déployer sur CT201
|
||||
|
||||
```bash
|
||||
# Méthode A : Exécuter le script de déploiement
|
||||
bash /opt/git-repos/homelab-config/status-monitor/deploy.sh
|
||||
|
||||
# Méthode B : Manuellement
|
||||
ssh root@192.168.0.201
|
||||
cd /opt/status-monitor
|
||||
|
||||
# Cloner ou pull le dépôt
|
||||
if [ ! -d "homelab-config" ]; then
|
||||
git clone https://VisualPCI:3N14E7GWVSgi3K@git.peis.fr/VisualPCI/homelab-config.git
|
||||
else
|
||||
cd homelab-config
|
||||
git pull
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Copier les fichiers
|
||||
cp -f homelab-config/status-monitor/app.py .
|
||||
cp -f homelab-config/status-monitor/status-monitor.service /etc/systemd/system/
|
||||
|
||||
# Redémarrer
|
||||
systemctl daemon-reload
|
||||
systemctl restart status-monitor
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📦 Versioning
|
||||
|
||||
### Règles de versioning
|
||||
- Format : `MAJOR.MINOR.PATCH` (ex: 1.1.0)
|
||||
- **MAJOR** : Changements incompatibles (refonte complète)
|
||||
- **MINOR** : Nouvelles fonctionnalités (compatibles)
|
||||
- **PATCH** : Corrections de bugs
|
||||
|
||||
### Mettre à jour la version
|
||||
|
||||
```bash
|
||||
# 1. Modifier le fichier VERSION
|
||||
nano status-monitor/VERSION
|
||||
|
||||
# 2. Créer un tag Git (optionnel pour les releases)
|
||||
git tag -a v1.1.0 -m "Release Status Monitor v1.1.0"
|
||||
git push origin v1.1.0
|
||||
|
||||
# 3. Commit le changement de version
|
||||
git add status-monitor/VERSION
|
||||
git commit -m "Bump version to 1.1.0"
|
||||
git push
|
||||
```
|
||||
|
||||
### Historique des versions
|
||||
| Version | Date | Changements |
|
||||
|---------|------|-------------|
|
||||
| 1.1.0 | 19/07/2026 | Version initiale dans Git |
|
||||
| 1.0.0 | Avant | Version initiale (non versionnée) |
|
||||
|
||||
---
|
||||
|
||||
## 📊 Configuration des Services
|
||||
|
||||
Les services à surveiller sont définis dans le dictionnaire `SERVICES` dans `app.py`.
|
||||
|
||||
**Format** :
|
||||
```python
|
||||
SERVICES = {
|
||||
"service_id": {
|
||||
"name": "Nom affiché",
|
||||
"type": "ssh" | "http" | "https",
|
||||
"host": "IP ou hostname",
|
||||
"port": port_number,
|
||||
"url": "/chemin" (optionnel, pour http/https),
|
||||
"insecure": True | False (optionnel, pour https sans vérification SSL)
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
**Types disponibles** :
|
||||
- `ssh` : Vérifie si le port SSH (22) est ouvert
|
||||
- `http` : Vérifie la réponse HTTP sur un port
|
||||
- `https` : Vérifie la réponse HTTPS sur un port
|
||||
|
||||
---
|
||||
|
||||
## 🎨 API Endpoints
|
||||
|
||||
| Endpoint | Méthode | Description |
|
||||
|----------|---------|-------------|
|
||||
| `/` | GET | Tableau de bord HTML |
|
||||
| `/api/status` | GET | JSON de tous les statuts |
|
||||
| `/api/refresh` | GET | Rafraîchit tous les services |
|
||||
| `/api/check/<service_id>` | GET | Vérifie un service spécifique |
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuration Traefik
|
||||
|
||||
Le service est exposé via Traefik sur CT200 avec la configuration suivante dans `dynamic.yml` :
|
||||
|
||||
```yaml
|
||||
http:
|
||||
routers:
|
||||
status-monitor:
|
||||
rule: "Host(`status.peis.fr`)"
|
||||
entryPoints:
|
||||
- "websecure"
|
||||
tls:
|
||||
certResolver: "letsencrypt"
|
||||
service: status-monitor
|
||||
|
||||
services:
|
||||
status-monitor:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://192.168.0.201:80"
|
||||
```
|
||||
|
||||
**URL publique** : https://status.peis.fr
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Commandes Utiles
|
||||
|
||||
### Sur CT201
|
||||
|
||||
```bash
|
||||
# Voir les logs
|
||||
journalctl -u status-monitor -f
|
||||
|
||||
# Redémarrer
|
||||
systemctl restart status-monitor
|
||||
|
||||
# Tester localement
|
||||
curl http://localhost
|
||||
curl http://localhost/api/status | jq
|
||||
```
|
||||
|
||||
### Depuis l'extérieur
|
||||
|
||||
```bash
|
||||
# Vérifier l'accès
|
||||
curl -vk https://status.peis.fr
|
||||
curl -vk https://status.peis.fr/api/status
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Développement
|
||||
|
||||
### Ajouter un nouveau service
|
||||
|
||||
1. Éditer `app.py`
|
||||
2. Ajouter une entrée dans `SERVICES`
|
||||
3. Tester localement
|
||||
4. Pousser vers Git
|
||||
5. Déployer
|
||||
|
||||
### Tester localement
|
||||
|
||||
```bash
|
||||
# Sur ta machine de dev
|
||||
python3 app.py
|
||||
# Accéder à http://localhost:80
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 Credentials et Accès
|
||||
|
||||
| Élément | Valeur |
|
||||
|---------|--------|
|
||||
| **Dépôt Git** | git.peis.fr/VisualPCI/homelab-config |
|
||||
| **Username Git** | VisualPCI |
|
||||
| **Token Git** | 3N14E7GWVSgi3K |
|
||||
| **Serveur de déploiement** | CT201 (192.168.0.201) |
|
||||
| **URL publique** | https://status.peis.fr |
|
||||
| **Port** | 80 |
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Prochaines Évolutions
|
||||
|
||||
- [ ] Ajouter l'authentification basique
|
||||
- [ ] Ajouter des notifications (email, webhook)
|
||||
- [ ] Intégrer avec Grafana/Prometheus
|
||||
- [ ] Historique persistant en base de données
|
||||
- [ ] Dashboard personnalisable
|
||||
|
||||
---
|
||||
|
||||
*Documentation générée par Mistral Vibe - 19/07/2026*
|
||||
@@ -0,0 +1 @@
|
||||
1.1.0
|
||||
+40
-34
@@ -1,34 +1,40 @@
|
||||
#!/bin/bash
|
||||
# Scipt de déploiement DevOps pou status-monito
|
||||
# Utilisation: wsl bash ~/homelab-config/status-monito/deploy.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "[DEPLOY] Début du déploiement depuis Git..."
|
||||
|
||||
# Se connecte à CT201 et déploye
|
||||
ssh oot@192.168.0.201 << 'ENDSSH'
|
||||
cd /opt/status-monito
|
||||
|
||||
echo "[DEPLOY] Mise à jou depuis Git..."
|
||||
if [ ! -d "homelab-config" ]; then
|
||||
git clone https://VisualPCI:3N14E7GWVSgi3K@git.peis.f/VisualPCI/homelab-config.git
|
||||
echo "[DEPLOY] Dépôt cloné"
|
||||
else
|
||||
cd homelab-config
|
||||
git pull
|
||||
echo "[DEPLOY] Dépôt mis à jou"
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo "[DEPLOY] Copie des fichies..."
|
||||
cp -f homelab-config/status-monito/app.py .
|
||||
cp -f homelab-config/status-monito/dynamic_taefik.yml .
|
||||
|
||||
echo "[DEPLOY] Redémaage du sevice..."
|
||||
systemctl estat status-monito
|
||||
|
||||
echo "[DEPLOY] ✅ Déploiement teminé !"
|
||||
ENDSSH
|
||||
|
||||
echo "[DEPLOY] Déploiement teminé avec succès !"
|
||||
#!/bin/bash
|
||||
# Script de déploiement DevOps pour status-monitor
|
||||
# Utilisation: wsl bash ~/homelab-config/status-monitor/deploy.sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "[DEPLOY] Début du déploiement depuis Git..."
|
||||
|
||||
# Se connecte à CT201 et déploye
|
||||
ssh root@192.168.0.201 << 'ENDSSH'
|
||||
cd /opt/status-monitor
|
||||
|
||||
echo "[DEPLOY] Mise à jour depuis Git..."
|
||||
if [ ! -d "homelab-config" ]; then
|
||||
git clone https://VisualPCI:3N14E7GWVSgi3K@git.peis.fr/VisualPCI/homelab-config.git
|
||||
echo "[DEPLOY] Dépôt cloné"
|
||||
else
|
||||
cd homelab-config
|
||||
git pull
|
||||
echo "[DEPLOY] Dépôt mis à jour"
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo "[DEPLOY] Copie des fichiers..."
|
||||
cp -f homelab-config/status-monitor/app.py .
|
||||
|
||||
# Copier le service systemd si présent
|
||||
if [ -f "homelab-config/status-monitor/status-monitor.service" ]; then
|
||||
cp -f homelab-config/status-monitor/status-monitor.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
echo "[DEPLOY] Service systemd mis à jour"
|
||||
fi
|
||||
|
||||
echo "[DEPLOY] Redémarrage du service..."
|
||||
systemctl restart status-monitor
|
||||
|
||||
echo "[DEPLOY] ✅ Déploiement terminé !"
|
||||
ENDSSH
|
||||
|
||||
echo "[DEPLOY] Déploiement terminé avec succès !"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Homelab Status Monitor
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/python3 /opt/status-monitor/app.py
|
||||
WorkingDirectory=/opt/status-monitor
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
User=root
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user