Public Access
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import os
|
|
import shutil
|
|
import requests
|
|
|
|
def obtenir_infos_serveur():
|
|
# Espace disque racine /
|
|
total, used, free = shutil.disk_usage("/")
|
|
|
|
# Espace disque /DATA (partition principale / RAID)
|
|
data_stats = {}
|
|
if os.path.exists("/DATA"):
|
|
dt, du, df = shutil.disk_usage("/DATA")
|
|
data_stats = {
|
|
"total_gb": round(dt / (2**30), 2),
|
|
"utilise_gb": round(du / (2**30), 2),
|
|
"libre_gb": round(df / (2**30), 2),
|
|
"pourcentage": round((du / dt) * 100, 1)
|
|
}
|
|
|
|
# État du RAID logiciel (/proc/mdstat)
|
|
raid_status = "RAID non actif ou non détecté"
|
|
if os.path.exists("/proc/mdstat"):
|
|
try:
|
|
with open("/proc/mdstat", "r") as f:
|
|
raid_status = f.read().strip()
|
|
except Exception as e:
|
|
raid_status = f"Erreur de lecture mdstat : {e}"
|
|
|
|
# État de l'Agent Vectoriel (Ollama)
|
|
agent_status = "Injoignable"
|
|
try:
|
|
resp = requests.get("http://172.19.0.1:11434/api/tags", timeout=2)
|
|
if resp.status_code == 200:
|
|
agent_status = "Actif (Ollama & Embeddings en ligne)"
|
|
else:
|
|
agent_status = f"Répond (Code HTTP {resp.status_code})"
|
|
except Exception:
|
|
agent_status = "Hors ligne / Injoignable"
|
|
|
|
return {
|
|
"disque_total_gb": round(total / (2**30), 2),
|
|
"disque_utilise_gb": round(used / (2**30), 2),
|
|
"disque_libre_gb": round(free / (2**30), 2),
|
|
"pourcentage_utilise": round((used / total) * 100, 1),
|
|
"data_stats": data_stats,
|
|
"raid_status": raid_status,
|
|
"agent_status": agent_status
|
|
} |