Files
html/api/qa-hub-api.php
2026-04-16 13:30:02 +02:00

29 lines
2.4 KiB
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$p=0;$f=0;$r=[];
function t($n,$c,$d=''){global $p,$f,$r;$c?$p++:$f++;$r[]=['n'=>$n,'s'=>$c?'P':'F','d'=>$d];}
t('site',@file_get_contents('https://weval-consulting.com/')!==false,'HTTP OK');
t('docker',intval(trim(shell_exec('docker ps -q|wc -l')))>=7,trim(shell_exec('docker ps -q|wc -l')).' containers');
$nr=json_decode(@file_get_contents('/var/www/html/api/l99-state.json'),1);
$nrp=$nr['pass']??0;$nrt=$nr['total']??0;
t('nonreg',$nrp==$nrt&&$nrt>0,"$nrp/$nrt");
t('ports',intval(trim(shell_exec("ss -tlnp|grep LISTEN|wc -l")))>30,trim(shell_exec("ss -tlnp|grep LISTEN|wc -l")).' ports');
$ssl=trim(shell_exec("echo|openssl s_client -connect weval-consulting.com:443 2>/dev/null|openssl x509 -noout -enddate 2>/dev/null"));
t('ssl',!empty($ssl),$ssl);
t('qdrant',count((json_decode(@file_get_contents('http://127.0.0.1:6333/collections'),1)['result']['collections']??[]))>=4);
t('disk',intval(trim(shell_exec("df / --output=pcent|tail -1|tr -d ' %'")))<=90,trim(shell_exec("df / --output=pcent|tail -1|tr -d ' %'")).'%');
t('load',floatval(trim(shell_exec("cut -d' ' -f1 /proc/loadavg")))<15,trim(shell_exec("cat /proc/loadavg")));
t('gold',intval(trim(shell_exec("find /opt/wevads/vault -type f 2>/dev/null|wc -l")))>100,trim(shell_exec("find /opt/wevads/vault -type f 2>/dev/null|wc -l")).' files');
t('keys',intval(trim(shell_exec("grep -c KEY /etc/weval/secrets.env 2>/dev/null")))>=10,trim(shell_exec("grep -c KEY /etc/weval/secrets.env 2>/dev/null")).' keys');
t('s95',trim(shell_exec("curl -skm5 -o /dev/null -w '%{http_code}' http://10.1.0.3:5890/"))=='200','S95 UP');
$bh=json_decode(@file_get_contents('https://weval-consulting.com/api/blade-tasks/heartbeat.json'),1);
t('blade',!empty($bh['cpu']),'CPU:'.$bh['cpu'].'%');
t('deepseek',trim(shell_exec("curl -skm3 -o /dev/null -w '%{http_code}' http://127.0.0.1:8901/health"))=='200','port 8901');
t('ollama',trim(shell_exec("curl -skm3 -o /dev/null -w '%{http_code}' http://127.0.0.1:11434/api/tags"))=='200','port 11434 embedding-only UP'); // DOCTRINE 16avr: embedding-only (nomic/weval-brain-v3), sovereign:4000 primary LLM
t('hubs',intval(trim(shell_exec("ls /var/www/html/*-hub.html 2>/dev/null|wc -l")))>=20,trim(shell_exec("ls /var/www/html/*-hub.html 2>/dev/null|wc -l")).' hubs');
$sigma=$f==0?'6':($f<=1?'5':($f<=2?'4':'3'));
echo json_encode(['pass'=>$p,'fail'=>$f,'total'=>$p+$f,'sigma'=>$sigma,'results'=>$r],JSON_PRETTY_PRINT);