Files
html/api/wevia-health.php
2026-04-16 02:28:32 +02:00

29 lines
895 B
PHP

<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
$status = "ok";
$checks = [];
// Ollama
$r = @file_get_contents("http://127.0.0.1:11434/api/tags");
$models = $r ? count(json_decode($r,true)["models"] ?? []) : 0;
$checks["ollama"] = $models > 0;
if (!$checks["ollama"]) { $status = "degraded"; shell_exec("systemctl restart ollama 2>/dev/null"); }
// Qdrant
$r2 = @file_get_contents("http://127.0.0.1:6333/collections");
$checks["qdrant"] = $r2 !== false;
// PHP
$checks["php"] = true;
// Disk
$disk = intval(trim(shell_exec("df / | awk 'NR==2{print $5}' | tr -d '%'")));
$checks["disk"] = $disk < 90;
// RAM
$ram = intval(trim(shell_exec("free | awk '/Mem/{printf(\"%.0f\", $3/$2*100)}'")));
$checks["ram"] = $ram < 90;
echo json_encode(["status"=>$status,"models"=>$models,"disk"=>$disk."%","ram"=>$ram."%","checks"=>$checks,"ts"=>date("H:i")]);