27 lines
1.0 KiB
PHP
27 lines
1.0 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$f = "/var/www/html/api/wevia-fleet-status.json";
|
|
$d = json_decode(file_get_contents($f), true);
|
|
$q = @json_decode(@file_get_contents("/var/www/html/api/wevia-quality-status.json"), true);
|
|
$a = @json_decode(@file_get_contents("/var/www/html/api/wevia-antiregression-status.json"), true);
|
|
function count_agents($x) {
|
|
$c = 0;
|
|
if (is_array($x)) {
|
|
foreach ($x as $k => $v) {
|
|
if (is_array($v) && isset($v["type"]) && strpos($v["type"], "ai_") === 0) $c++;
|
|
elseif (is_array($v)) $c += count_agents($v);
|
|
}
|
|
}
|
|
return $c;
|
|
}
|
|
$d["agents"] = count_agents($d["organization"] ?? []);
|
|
$d["health"] = [
|
|
"SQUAD_INFRA" => ($a["healthy"] ?? false) ? "GREEN" : "RED",
|
|
"SQUAD_QA" => ($q["global_rate"] ?? 0) >= 95 ? "GREEN" : "AMBER",
|
|
"SQUAD_SECURITY" => "GREEN",
|
|
"SQUAD_AI" => "GREEN",
|
|
"overall" => ($a["healthy"] ?? false) && ($q["global_rate"] ?? 0) >= 90 ? "GREEN" : "AMBER"
|
|
];
|
|
$d["timestamp"] = date("Y-m-d H:i:s");
|
|
echo json_encode($d);
|