Skip to content

Commit 2f5e4b5

Browse files
committed
refact: fleet server
1 parent 33c2b73 commit 2f5e4b5

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎fleet-server/server.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ app.get('/ui', requireAuth, (req, res) => {
9898
id: c.id,
9999
hostname: c.hostname || '-',
100100
connection: c.status,
101+
state: (c.metrics?.app_state?.iac_state !== "idle" ? c.metrics?.app_state?.iac_state : c.metrics?.state?.state),
102+
last_update: c.metrics?.app_state?.last_iac_update ?? c.metrics?.state?.last_update_date,
101103
metrics: c.metrics || { resources: {}, state: {} }
102104
}));
103105
res.render('clients', { clients: list });
@@ -194,10 +196,10 @@ wss.on('connection', (ws) => {
194196
saveClients(clients);
195197
}
196198
} else if (msg.type === 'metrics') {
197-
const { uuid, state, resources } = msg;
199+
const { uuid, state, resources, app_state } = msg;
198200
if (uuid && clients[uuid]) {
199201
clients[uuid].last_seen = new Date().toISOString();
200-
clients[uuid].metrics = { state, resources, collected_at: new Date().toISOString() };
202+
clients[uuid].metrics = { state, resources, app_state, collected_at: new Date().toISOString() };
201203
}
202204
}
203205
});

‎fleet-server/views/clients.handlebars‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<tr>
2222
<td title="{{id}}">{{hostname}}</td>
2323
<td class="status-{{connection}}">{{connection}}</td>
24-
<td class="status-{{metrics.state.state}}">{{metrics.state.state}}</td>
24+
<td class="status-{{state}}">{{state}}</td>
2525
<td class="version">{{metrics.state.version}}</td>
26-
<td class="last_update">{{formatDate metrics.state.last_update_date}}</td>
26+
<td class="last_update">{{formatDate last_update}}</td>
2727
<td class="metrics-cell">{{metrics.resources.cpu_usage}}{{#if metrics.resources.cpu_usage}}%{{/if}}</td>
2828
<td class="metrics-cell">{{metrics.resources.ram_percent}}{{#if metrics.resources.ram_percent}}%{{/if}}</td>
2929
<td class="metrics-cell">{{metrics.resources.disk_percent}}{{#if metrics.resources.disk_percent}}%{{/if}}</td>

0 commit comments

Comments
 (0)