count($apis),"list"=>array_map("basename",$apis)]; // HTML pages $htmls = glob("/var/www/html/*.html"); $r["pages"] = ["count"=>count($htmls),"list"=>array_map("basename",$htmls)]; // Crons $crons = glob("/etc/cron.d/weval-*"); $allcrons = glob("/etc/cron.d/*"); $r["crons"] = ["weval"=>count($crons),"total"=>count($allcrons),"list"=>array_map("basename",$crons)]; // Docker $dk = trim(shell_exec("docker ps --format '{{.Names}}' 2>/dev/null") ?? ""); $dkl = array_filter(explode("\n",$dk)); $r["docker"] = ["running"=>count($dkl),"list"=>$dkl]; // /opt repos $allopts = array_merge(glob("/opt/weval-*"),glob("/opt/deer-*"),glob("/opt/claw-*")); $r["repos"] = ["count"=>count($allopts),"list"=>array_map("basename",$allopts)]; // Disk $r["disk"] = ["s204_pct"=>round(100-disk_free_space("/")/disk_total_space("/")*100),"s204_free"=>round(disk_free_space("/")/1e9,1)."GB"]; // Ports S204 $ports = trim(shell_exec("ss -tlnp 2>/dev/null | grep LISTEN | awk '{print \$4}' | sed 's/.*://' | sort -nu | tr '\n' ' '") ?? ""); $r["ports_s204"] = ["list"=>$ports,"count"=>count(explode(" ",trim($ports)))]; // Ollama S204 $ol = @shell_exec("curl -s --max-time 3 http://localhost:11434/api/tags 2>/dev/null"); $old = json_decode($ol??"",true); $models = []; foreach($old["models"]??[] as $m) $models[] = $m["name"]." (".round($m["size"]/1e9,1)."GB)"; $r["ollama_s204"] = ["count"=>count($models),"models"=>$models]; // Ollama S151 $ol2 = @shell_exec("curl -s --max-time 3 http://151.80.235.110:11434/api/tags 2>/dev/null"); $od2 = json_decode($ol2??"",true); $m2 = []; foreach($od2["models"]??[] as $m) $m2[] = $m["name"]." (".round($m["size"]/1e9,1)."GB)"; $r["ollama_s151"] = ["count"=>count($m2),"models"=>$m2]; // Health endpoints $healths = ["health","health-ollama","health-qdrant","health-mm","health-n8n","health-plausible","health-searxng","health-twenty","health-kuma"]; $up = 0; foreach($healths as $h) { $hc = @file_get_contents("http://localhost/api/{$h}.php"); if($hc && (stripos($hc,"ok")!==false || stripos($hc,"up")!==false || stripos($hc,"true")!==false)) $up++; } $r["health"] = ["up"=>$up,"total"=>count($healths)]; // S95 $s95 = @shell_exec("curl -s --max-time 3 'http://10.1.0.3:5890/api/sentinel-brain.php?action=exec&cmd=echo+OK' 2>/dev/null"); $r["s95"] = ["sentinel"=>strpos($s95??"","OK")!==false?"UP":"DOWN"]; // S151 $s151 = @shell_exec("curl -s --max-time 3 'http://151.80.235.110:11434/api/tags' 2>/dev/null | head -c 10"); $r["s151"] = ["ollama"=>strlen($s151??"")>3?"UP":"DOWN"]; // Secrets count $kc = 0; $ks = @file("/etc/weval/secrets.env"); if($ks) foreach($ks as $l) if(strpos($l,"=")!==false && $l[0]!="#") $kc++; $r["credentials"] = $kc; // Guardian $g = @file_get_contents("/opt/weval-guardian/gold-checksums.json"); $gd = json_decode($g??"{}",true); $r["guardian"] = ["files"=>count($gd),"status"=>"active"]; // UX Agent $ux = @file_get_contents("/var/www/html/api/ux-agent-report.json"); $uxd = json_decode($ux??"{}",true); $r["ux_agent"] = ["score"=>$uxd["score"]??0,"features"=>($uxd["features"]["pass"]??0)."/".($uxd["features"]["total"]??0)]; // Summary $r["summary"] = [ "apis"=>$r["apis"]["count"], "pages"=>$r["pages"]["count"], "crons"=>$r["crons"]["total"], "docker"=>$r["docker"]["running"], "repos"=>$r["repos"]["count"], "ports_s204"=>$r["ports_s204"]["count"], "ollama_s204"=>$r["ollama_s204"]["count"], "ollama_s151"=>$r["ollama_s151"]["count"], "health"=>$r["health"]["up"]."/".$r["health"]["total"], "disk_s204"=>$r["disk"]["s204_pct"]."%", "credentials"=>$r["credentials"], "guardian"=>$r["guardian"]["files"]." GOLD", "ux"=>$r["ux_agent"]["score"]."%", "s95"=>$r["s95"]["sentinel"], "s151"=>$r["s151"]["ollama"], ]; // Search filter if($q !== "all" && $q !== "summary") { $f = []; foreach($r as $k=>$v) { if(stripos($k,$q)!==false) $f[$k]=$v; if(is_array($v)) { foreach($v as $sk=>$sv) { if(is_string($sv) && stripos($sv,$q)!==false) { $f[$k.".".$sk]=$sv; } if(is_array($sv)) { $hits = array_filter($sv,function($i)use($q){return is_string($i)&&stripos($i,$q)!==false;}); if($hits) $f[$k."_matches"]=array_values($hits); } } } } if($f) { echo json_encode($f,JSON_PRETTY_PRINT); exit; } } if($q === "summary") { echo json_encode($r["summary"],JSON_PRETTY_PRINT); exit; } echo json_encode($r,JSON_PRETTY_PRINT);