// Fake agents that stream telemetry shaped like the real PGX samples, to exercise the dashboard UI. const token = process.argv[2]; const ws = new WebSocket('ws://127.0.0.1:8080/ws/agent', { headers: { Authorization: 'Bearer ' + token } }); let t0 = Date.now(); ws.onopen = () => { const tick = () => { const k = (Date.now() - t0) / 1000; const cpu = 20 + 15 * Math.sin(k / 6) + Math.random() * 5; const sample = { ts: Math.floor(Date.now() / 1000), agent_version: '0.3.0', uptime_s: 44284, cpus: 20, cpu_pct: cpu, load: [0.02, 0.12, 0.08], mem_total: 130660188160, mem_avail: 130660188160 - (18e9 + 4e9 * Math.sin(k / 9)), swap_used: 0, gpu: { util: Math.max(0, Math.round(35 + 40 * Math.sin(k / 5))), temp: 52, power_w: 38.4, sm_mhz: 1800, pstate: 'P0', apps: ['ollama'] }, temp_cpu: 39.4, temp_nvme: 36.85, disk: { path: '/mnt/models/ollama', free: 933322088448, total: 983349043200, mounted: true }, ollama: { up: true, loaded: [{ name: 'qwen2.5-coder:7b', size: 5200000000, expires_at: 'x' }] }, owner_idle_s: 603, }; ws.send(JSON.stringify({ t: 'stats', data: sample })); }; tick(); setInterval(tick, 2000); }; ws.onclose = () => process.exit(0);