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);