mirror of
https://github.com/Alkatrazz24/Funk-lab.git
synced 2026-07-08 16:24:43 +02:00
feat(stt): enrichit les sondes (host_health, cluster_status, metrics) (#52)
- host_health : ajoute CPU%, disque /%, température CPU, uptime ; pour gpu-01 un bloc GPU complet (température, utilisation, VRAM%, puissance via rocm_scraper) en plus de llama-server. Requêtes concurrentes (asyncio.gather). - cluster_status : ajoute le nb de nœuds k8s Ready et une ligne CrashLoopBackOff (pods en boucle de crash) — complète le filtrage des pods terminés. - metrics_block (contexte grafana) : ajoute le résumé GPU (util/temp/VRAM). - Toutes les PromQL validées contre le Prometheus in-cluster. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
421ec77ef9
commit
0d09dec3dc
4 changed files with 88 additions and 34 deletions
|
|
@ -137,6 +137,10 @@ async def alerts_block(client: httpx.AsyncClient) -> str:
|
|||
async def cluster_block(client: httpx.AsyncClient) -> str:
|
||||
try:
|
||||
nodes = await _prom_query(client, 'up{job=~"storage-01|gpu-01-node"}')
|
||||
knodes = await _prom_query(
|
||||
client, 'count(kube_node_status_condition{condition="Ready",status="true"} == 1)'
|
||||
)
|
||||
ready = await _prom_query(client, 'count(kube_pod_status_ready{condition="true"} == 1)')
|
||||
# « Non prêt » = ready false ET pod ENCORE actif (Running/Pending). Sans le filtre de
|
||||
# phase, les pods de CronJob terminés (Succeeded/Failed — ex. sacrifice-assign-renfort)
|
||||
# comptent comme « non prêts » → fausse alarme. Le join exclut les pods terminés.
|
||||
|
|
@ -145,20 +149,25 @@ async def cluster_block(client: httpx.AsyncClient) -> str:
|
|||
'kube_pod_status_ready{condition="false"} == 1'
|
||||
' and on(namespace,pod) kube_pod_status_phase{phase=~"Running|Pending"} == 1',
|
||||
)
|
||||
ready = await _prom_query(client, 'count(kube_pod_status_ready{condition="true"} == 1)')
|
||||
crash = await _prom_query(
|
||||
client, 'kube_pod_container_status_waiting_reason{reason="CrashLoopBackOff"} == 1'
|
||||
)
|
||||
except httpx.HTTPError:
|
||||
return "Données indisponibles : Prometheus injoignable."
|
||||
hosts_up = sum(1 for _, v in nodes if v == 1)
|
||||
lines = [f"Hôtes hors-cluster joignables : {hosts_up}/{len(nodes) or 2} (storage-01, gpu-01)."]
|
||||
if knodes:
|
||||
lines.append(f"Nœuds k8s Ready : {int(knodes[0][1])}.")
|
||||
if ready:
|
||||
lines.append(f"Pods prêts (cluster) : {int(ready[0][1])}.")
|
||||
lines.append(f"Pods prêts : {int(ready[0][1])}.")
|
||||
if not_ready:
|
||||
names = ", ".join(
|
||||
m.get("pod", "?") for m, _ in not_ready[:6] if m.get("pod")
|
||||
)
|
||||
names = ", ".join(m.get("pod", "?") for m, _ in not_ready[:6] if m.get("pod"))
|
||||
lines.append(f"Pods NON prêts : {names or len(not_ready)}.")
|
||||
else:
|
||||
lines.append("Tous les pods scrutés sont prêts.")
|
||||
lines.append("Tous les pods actifs sont prêts.")
|
||||
if crash:
|
||||
cnames = ", ".join(sorted({m.get("pod", "?") for m, _ in crash[:6]}))
|
||||
lines.append(f"⚠️ CrashLoopBackOff : {cnames}.")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
|
|
@ -167,11 +176,23 @@ async def metrics_block(client: httpx.AsyncClient) -> str:
|
|||
llama = await _prom_query(client, 'up{job="llama-server-gpu"}')
|
||||
targets_up = await _prom_query(client, 'count(up == 1)')
|
||||
targets_all = await _prom_query(client, 'count(up)')
|
||||
gpu_util = await _prom_query(client, 'rocm_gpu_utilization_percent')
|
||||
gpu_temp = await _prom_query(client, 'rocm_gpu_temperature_celsius')
|
||||
gpu_vram = await _prom_query(client, '100*rocm_vram_used_bytes/rocm_vram_total_bytes')
|
||||
except httpx.HTTPError:
|
||||
return "Données indisponibles : Prometheus injoignable."
|
||||
lines = []
|
||||
if llama:
|
||||
lines.append("llama-server (GPU) : " + ("en ligne" if llama[0][1] == 1 else "hors ligne") + ".")
|
||||
if gpu_util or gpu_temp or gpu_vram:
|
||||
g = []
|
||||
if gpu_util:
|
||||
g.append(f"utilisation {round(gpu_util[0][1])}%")
|
||||
if gpu_temp:
|
||||
g.append(f"{round(gpu_temp[0][1])}°C")
|
||||
if gpu_vram:
|
||||
g.append(f"VRAM {round(gpu_vram[0][1])}%")
|
||||
lines.append("GPU RX 6700XT : " + ", ".join(g) + ".")
|
||||
if targets_up and targets_all:
|
||||
lines.append(f"Cibles Prometheus UP : {int(targets_up[0][1])}/{int(targets_all[0][1])}.")
|
||||
return "\n".join(lines) if lines else "Aucune métrique disponible."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue