Show System metrics in hosts page

Implement simple collection of basic real time system metrics of hosts
and the controller for the purpose of displaying them in the Web UI. The
metrics are collected by the controller at a configurable interval and
pushed out to web clients currently subscribed to the metrics.
This commit is contained in:
Hornwitser committed 2024-01-14 09:57:44 +01:00
1 parent 69bdc8e884
commit d64bf6015e
13 files changed
+409 -7

No files matched your search

@@ -0,0 +1,8 @@
import { useCallback, useContext, useSyncExternalStore } from "react";
import ControlContext from "../components/ControlContext";
export function useSystemMetrics() {
const control = useContext(ControlContext);
const subscribe = useCallback((callback: () => void) => control.systemMetrics.subscribe(callback), [control]);
return useSyncExternalStore(subscribe, () => control.systemMetrics.getSnapshot());
}