mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 23:55:23 +00:00
feat: make each plugin an npm workspace built by a termix-plugin CLI
This commit is contained in:
1 parent
4758016f41
commit
5796186a1c
448 files changed
+3087
-2003
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { ServerMetrics } from "@/main-axios";
|
||||
|
||||
/**
|
||||
* Coarse fingerprint of a metrics poll. Adaptive polling backs off while it
|
||||
* stays the same, so it must move whenever something a card shows changes.
|
||||
*/
|
||||
export function metricsChangeKey(data: ServerMetrics): string {
|
||||
const bucket = (value: number | null | undefined) =>
|
||||
value == null ? null : Math.round(value / 5) * 5;
|
||||
return JSON.stringify({
|
||||
cpu: bucket(data.cpu.percent),
|
||||
memory: bucket(data.memory.percent),
|
||||
disk: bucket(data.disk.percent),
|
||||
running: data.processes?.running ?? null,
|
||||
ports: data.ports?.ports?.length ?? 0,
|
||||
firewall: data.firewall?.status ?? null,
|
||||
gpus:
|
||||
data.gpu?.gpus?.map((gpu) => [
|
||||
bucket(gpu.utilizationPercent),
|
||||
bucket(gpu.memoryPercent),
|
||||
]) ?? [],
|
||||
gpuProcesses: data.gpu?.processes?.length ?? 0,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user