Initial implementation of nice Nodes page

This commit is contained in:
Joshua Boniface 2025-02-28 19:53:44 -05:00
parent e52211e326
commit 11e1e8eec4
2 changed files with 1213 additions and 4 deletions

View File

@ -113,6 +113,50 @@ const updateMetricsHistory = (timestamp, status) => {
data data
}; };
}); });
// Track node-specific metrics
if (!metricsHistory.value.nodes) {
metricsHistory.value.nodes = {};
}
// Update metrics for each node
nodeData.value.forEach(node => {
const nodeName = node.name;
if (!metricsHistory.value.nodes[nodeName]) {
metricsHistory.value.nodes[nodeName] = {
health: { labels: [], data: [] },
cpu: { labels: [], data: [] },
memory: { labels: [], data: [] },
allocated: { labels: [], data: [] }
};
}
// Calculate node metrics
const nodeMetrics = {
health: node.health || 0,
cpu: node.load && node.cpu_count ? Math.round((node.load / node.cpu_count) * 100) : 0,
memory: node.memory?.used && node.memory?.total ? Math.round((node.memory.used / node.memory.total) * 100) : 0,
allocated: node.memory?.allocated && node.memory?.total ? Math.round((node.memory.allocated / node.memory.total) * 100) : 0
};
// Update each metric for this node
Object.keys(nodeMetrics).forEach(metric => {
const nodeLabels = [...metricsHistory.value.nodes[nodeName][metric].labels, timestamp];
const nodeData = [...metricsHistory.value.nodes[nodeName][metric].data, nodeMetrics[metric]];
// Keep only last 180 points
if (nodeLabels.length > 180) {
nodeLabels.shift();
nodeData.shift();
}
metricsHistory.value.nodes[nodeName][metric] = {
labels: nodeLabels,
data: nodeData
};
});
});
}; };
const updateDashboard = async () => { const updateDashboard = async () => {

File diff suppressed because it is too large Load Diff