Files
html/api/agent-status.php
2026-04-12 22:57:03 +02:00

72 lines
2.8 KiB
PHP

<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
// Real-time agent activity from system
$agents = [];
// Check cron processes
exec("ps aux | grep -E 'python3|node|bash.*cron|php.*cron' | grep -v grep", $procs);
$active_map = [
"mirofish" => ["MiroFish", "Auto-guérison en cours..."],
"paperclip" => ["Paperclip", "Fleet scan 669 agents..."],
"l99-alive" => ["L99 Pilot", "Health check 24 URLs..."],
"l99-state" => ["State Updater", "Mise à jour état..."],
"deerflow" => ["DeerFlow", "Deep research active..."],
"director" => ["Director", "Observation 39 métriques..."],
"l99-pipeline" => ["L99 Pilot", "Pipeline qualité..."],
"blade" => ["Blade", "Sync desktop..."],
"nonreg" => ["NonReg", "Tests régression 151/153..."],
"guardian" => ["Infra Guardian", "Scan sécurité..."],
"port-protection" => ["Security", "Protection ports..."],
"autonomous" => ["WEVIA Master", "Orchestration autonome..."],
"watchdog" => ["Blade", "Watchdog 60s..."],
"fiability" => ["Fiability", "Vérification URLs..."],
"godmode" => ["L99 Pilot", "GODMODE v2 test..."],
"ux-agent" => ["UX Agent", "Scan UX visual..."],
"autolearn" => ["AutoLearn", "Apprentissage auto..."],
"ethica" => ["Ethica", "Enrichissement HCP..."],
"oss-trending" => ["ArchScan", "OSS trending scan..."],
"ai-benchmark" => ["AI Benchmark", "Benchmark providers..."],
"health-check" => ["Monitor", "Health check global..."],
"daily-brief" => ["WEVIA Master", "Brief quotidien TG..."],
];
$active = [];
foreach ($procs as $proc) {
foreach ($active_map as $key => $info) {
if (stripos($proc, $key) !== false) {
$active[$info[0]] = $info[1];
}
}
}
// Always-active agents
$always = [
"WEVIA Master" => "Orchestration souveraine 24/7",
"Director" => "Observation continue */15min",
"Ollama" => "LLM local 10 modèles ready",
"Groq" => "API <200ms standby",
"Sentinel" => "Relais S95 actif",
"Docker" => count(explode("\n", trim(shell_exec("docker ps -q 2>/dev/null")))) . " containers UP",
"PMTA" => "MTA sacré port 25 actif",
"Qdrant" => "RAG vectors ready",
];
foreach ($always as $name => $msg) {
if (!isset($active[$name])) $active[$name] = $msg;
}
// ALERTS
$alerts = [];
$disk = intval(shell_exec("df / | tail -1 | awk '{print $5}' | tr -d '%'"));
if ($disk > 85) $alerts[] = ["agent"=>"Docker","msg"=>"Disk ".$disk."%"];
$dk = intval(shell_exec("docker ps -q 2>/dev/null | wc -l"));
if ($dk < 15) $alerts[] = ["agent"=>"Docker","msg"=>$dk." containers"];
$ol = intval(shell_exec("curl -s --max-time 2 http://localhost:11434/api/tags 2>/dev/null | grep -c name"));
if ($ol < 4) $alerts[] = ["agent"=>"Ollama","msg"=>$ol." models"];
echo json_encode(["active" => $active, "alerts" => $alerts, "total" => count($active), "ts" => date("H:i:s")]);