31 lines
1.5 KiB
PHP
31 lines
1.5 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
echo json_encode([
|
|
"uptime" => trim(shell_exec("uptime")),
|
|
"nginx_error_tail" => substr(shell_exec("tail -15 /var/log/nginx/error.log 2>&1"), 0, 1500),
|
|
"fpm_error_tail" => substr(shell_exec("tail -10 /var/log/php8.4-fpm.log 2>&1 || tail -10 /var/log/php8.3-fpm.log 2>&1"), 0, 1000),
|
|
"cascade_test" => (function(){
|
|
$t0 = microtime(true);
|
|
$ctx = stream_context_create(["http"=>["method"=>"POST","header"=>"Content-Type: application/json\r\n","content"=>json_encode(["model"=>"fast","messages"=>[["role"=>"user","content"=>"Hi"]],"max_tokens"=>20]),"timeout"=>5]]);
|
|
$r = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, $ctx);
|
|
return ["ok"=>(bool)$r, "elapsed_ms"=>round((microtime(true)-$t0)*1000), "resp"=>substr($r?:"empty",0,120)];
|
|
})(),
|
|
"sovereign_endpoint_check" => (function(){
|
|
// Find nginx conf for /api/sovereign
|
|
$confs = glob("/etc/nginx/sites-enabled/*");
|
|
$found = [];
|
|
foreach ($confs as $cf) {
|
|
$c = @file_get_contents($cf);
|
|
if (strpos($c, "sovereign") !== false) {
|
|
$lines = explode("\n", $c);
|
|
foreach ($lines as $i => $l) {
|
|
if (strpos($l, "sovereign") !== false) {
|
|
$found[basename($cf)][] = "L" . ($i+1) . ": " . trim(substr($l, 0, 200));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $found;
|
|
})(),
|
|
]);
|