21 lines
761 B
PHP
21 lines
761 B
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$ctx = stream_context_create(["http"=>["timeout"=>5]]);
|
|
$h = @file_get_contents("http://127.0.0.1:4000/health", false, $ctx);
|
|
|
|
$test = @file_get_contents("http://127.0.0.1:4000/v1/chat/completions", false, 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"=>15]),
|
|
"timeout"=>15]
|
|
]));
|
|
|
|
$load = trim(shell_exec("uptime"));
|
|
$fpm = intval(shell_exec("pgrep -c php-fpm8"));
|
|
|
|
echo json_encode([
|
|
"health" => substr($h ?: "DOWN", 0, 300),
|
|
"direct_test" => substr($test ?: "FAILED", 0, 200),
|
|
"load" => $load,
|
|
"fpm" => $fpm,
|
|
], JSON_PRETTY_PRINT);
|