From 53b1c6b90a94021e5928a9c3515bfe2acbcfa4ba Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Sat, 30 May 2026 05:05:02 +0000 Subject: [PATCH] Fix agents_list: use JSON_EXTRACT on metric_data instead of non-existent columns --- public_html/admin/index.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public_html/admin/index.php b/public_html/admin/index.php index 2ffaa0a..6558168 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -71,7 +71,15 @@ if ($action) { // ── AGENTS ─────────────────────────────────────────────────────────── case 'agents_list': $agents = JarvisDB::query('SELECT agent_id, hostname, agent_type, ip_address, status, last_seen, created_at FROM registered_agents ORDER BY status="online" DESC, hostname'); - $metrics = JarvisDB::query('SELECT agent_id, cpu_pct, mem_pct, disk_pct FROM agent_metrics WHERE recorded_at > DATE_SUB(NOW(), INTERVAL 5 MINUTE) GROUP BY agent_id'); + $metrics = JarvisDB::query( + "SELECT agent_id, + ROUND(JSON_EXTRACT(metric_data,'$.cpu_percent'),1) AS cpu_pct, + ROUND(JSON_EXTRACT(metric_data,'$.memory.percent'),1) AS mem_pct, + ROUND(JSON_EXTRACT(metric_data,'$.disk[0].percent'),1) AS disk_pct + FROM agent_metrics + WHERE metric_type='system' AND recorded_at > DATE_SUB(NOW(), INTERVAL 5 MINUTE) + GROUP BY agent_id ORDER BY recorded_at DESC" + ); $mm = array_column($metrics, null, 'agent_id'); foreach ($agents as &$a) $a['metrics'] = $mm[$a['agent_id']] ?? null; j($agents);