Files
weval-l99/l99-mega-scanner.py.PAUSED
2026-04-13 12:43:21 +02:00

132 lines
4.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""L99 Mega Scanner — comprehensive benchmark writing l99-mega-benchmark.json + l99-mega-latest.json"""
import json, subprocess as sp, os, time, glob
from datetime import datetime
OUT_BENCH = "/var/www/html/api/l99-mega-benchmark.json"
OUT_LATEST = "/var/www/html/api/l99-mega-latest.json"
B = "https://weval-consulting.com"
def curl(u, timeout=8):
try:
r = sp.run(["curl", "-skL", "-o", "/dev/null", "-w", "%{http_code}|%{size_download}|%{time_total}",
"--max-time", str(timeout), u], capture_output=True, text=True, timeout=timeout+3)
p = r.stdout.strip().split("|")
return int(p[0]), int(p[1]), float(p[2])
except:
return 0, 0, 0.0
def body(u, timeout=8):
try:
r = sp.run(["curl", "-skL", "--max-time", str(timeout), u], capture_output=True, text=True, timeout=timeout+3)
return r.stdout
except:
return ""
categories = {}
total_pass = 0
total_tests = 0
# 1. HTML pages (sample)
html_files = sorted(glob.glob("/var/www/html/*.html"))[:30]
cat = {"pass": 0, "total": len(html_files), "fails": []}
for f in html_files:
name = os.path.basename(f)
c, s, t = curl(f"{B}/{name}")
if c in (200, 302, 301) and s > 0:
cat["pass"] += 1
else:
cat["fails"].append(f"{name}={c}/{s}B")
categories["html_sample"] = cat
total_pass += cat["pass"]; total_tests += cat["total"]
# 2. Critical APIs
apis = [
"nonreg-api.php", "ecosystem-health.php", "wevia-deep-test.php",
"l99-state.json", "architecture-index.json", "wevia-fleet.php",
"blade-api.php?k=BLADE2026&action=status", "weval-ia-fast.php",
"wevia-director.php?status", "openclaw-proxy.php"
]
cat = {"pass": 0, "total": len(apis), "fails": []}
for a in apis:
c, s, t = curl(f"{B}/api/{a}", timeout=15)
if c in (200, 201):
cat["pass"] += 1
else:
cat["fails"].append(f"{a.split('?')[0]}={c}")
categories["apis_critical"] = cat
total_pass += cat["pass"]; total_tests += cat["total"]
# 3. Subdomains
subs = ["paperclip","mirofish","wevads","n8n","deerflow","ethica"]
cat = {"pass": 0, "total": len(subs), "fails": []}
for s in subs:
c, sz, t = curl(f"https://{s}.weval-consulting.com/", timeout=10)
if c in (200, 301, 302, 401, 403):
cat["pass"] += 1
else:
cat["fails"].append(f"{s}={c}")
categories["subdomains"] = cat
total_pass += cat["pass"]; total_tests += cat["total"]
# 4. Docker containers
try:
r = sp.run(["docker", "ps", "--format", "{{.Names}}"], capture_output=True, text=True, timeout=10)
running = r.stdout.strip().split("\n") if r.stdout.strip() else []
cat = {"pass": len(running), "total": max(17, len(running)), "fails": []}
categories["docker"] = cat
total_pass += cat["pass"]; total_tests += cat["total"]
except:
categories["docker"] = {"pass": 0, "total": 17, "fails": ["docker unreachable"]}
total_tests += 17
# 5. Ollama models
try:
o = body("http://localhost:11435/api/tags")
d = json.loads(o) if o else {}
models = d.get("models", [])
cat = {"pass": len(models), "total": 4, "fails": []}
categories["ollama"] = cat
total_pass += min(cat["pass"], cat["total"]); total_tests += cat["total"]
except:
categories["ollama"] = {"pass": 0, "total": 4, "fails": ["ollama down"]}
total_tests += 4
# 6. Provider cascade (reachability only)
providers = [
("cerebras", "https://api.cerebras.ai/v1/models"),
("groq", "https://api.groq.com/openai/v1/models"),
("mistral", "https://api.mistral.ai/v1/models"),
("deepseek", "https://api.deepseek.com/models"),
("gemini", "https://generativelanguage.googleapis.com/v1beta/models"),
]
cat = {"pass": 0, "total": len(providers), "fails": []}
for name, url in providers:
c, s, t = curl(url, timeout=10)
if c > 0: # any response = reachable
cat["pass"] += 1
else:
cat["fails"].append(f"{name}=unreachable")
categories["providers"] = cat
total_pass += cat["pass"]; total_tests += cat["total"]
pct = round(total_pass * 100 / total_tests, 1) if total_tests else 0
result = {
"timestamp": datetime.utcnow().isoformat() + "Z",
"ts": datetime.utcnow().isoformat() + "Z",
"total_score": total_pass,
"max_score": total_tests,
"pct": pct,
"pass": total_pass,
"total": total_tests,
"fail": total_tests - total_pass,
"categories": categories,
}
with open("/tmp/_mega.json", "w") as f:
json.dump(result, f, indent=2)
sp.run(["cp", "/tmp/_mega.json", OUT_BENCH])
sp.run(["cp", "/tmp/_mega.json", OUT_LATEST])
print(f"MEGA: {total_pass}/{total_tests} = {pct}%")