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

14 lines
637 B
PHP

<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
$disk = "?";
exec("df / --output=pcent | tail -1", $o); if($o) $disk = trim($o[0]);
$ram = "?";
exec("free -m | grep Mem", $o2); if($o2){ $p=preg_split("/\s+/",trim($o2[0])); $ram=round($p[2]/1024,1)."G/".round($p[1]/1024,1)."G"; }
$om = 0;
$oj = @file_get_contents("http://localhost:11434/api/tags");
if ($oj) { $od = json_decode($oj, true); if($od) $om = count($od["models"] ?? []); }
$up = "?";
exec("uptime -p", $o3); if($o3) $up = str_replace("up ","",trim($o3[0]));
echo json_encode(["disk"=>$disk,"ram"=>$ram,"ollama"=>$om,"uptime"=>$up]);