mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
Fix agents_list: use JSON_EXTRACT on metric_data instead of non-existent columns
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user