From 0bad001ac94cfa2d69a2f824508468864195028e Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 18 Apr 2024 21:34:16 -0600 Subject: [PATCH] Show coral temps on system page if available (#11026) --- web/src/types/graph.ts | 5 ++ web/src/views/system/GeneralMetrics.tsx | 65 ++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/web/src/types/graph.ts b/web/src/types/graph.ts index 4963142e8..6a3eb7663 100644 --- a/web/src/types/graph.ts +++ b/web/src/types/graph.ts @@ -18,6 +18,11 @@ export const InferenceThreshold = { error: 100, } as Threshold; +export const DetectorTempThreshold = { + warning: 72, + error: 80, +} as Threshold; + export const DetectorCpuThreshold = { warning: 25, error: 50, diff --git a/web/src/views/system/GeneralMetrics.tsx b/web/src/views/system/GeneralMetrics.tsx index fe5e4dffe..7d2d5fc5a 100644 --- a/web/src/views/system/GeneralMetrics.tsx +++ b/web/src/views/system/GeneralMetrics.tsx @@ -5,6 +5,7 @@ import { useFrigateStats } from "@/api/ws"; import { DetectorCpuThreshold, DetectorMemThreshold, + DetectorTempThreshold, GPUMemThreshold, GPUUsageThreshold, InferenceThreshold, @@ -105,6 +106,44 @@ export default function GeneralMetrics({ return Object.values(series); }, [statsHistory]); + const detTempSeries = useMemo(() => { + if (!statsHistory) { + return []; + } + + if ( + statsHistory.length > 0 && + Object.keys(statsHistory[0].service.temperatures).length == 0 + ) { + return undefined; + } + + const series: { + [key: string]: { name: string; data: { x: number; y: number }[] }; + } = {}; + + statsHistory.forEach((stats, statsIdx) => { + if (!stats) { + return; + } + + Object.entries(stats.detectors).forEach(([key], cIdx) => { + if (cIdx <= Object.keys(stats.service.temperatures).length) { + if (!(key in series)) { + series[key] = { + name: key, + data: [], + }; + } + + const temp = Object.values(stats.service.temperatures)[cIdx]; + series[key].data.push({ x: statsIdx + 1, y: Math.round(temp) }); + } + }); + }); + return Object.values(series); + }, [statsHistory]); + const detCpuSeries = useMemo(() => { if (!statsHistory) { return []; @@ -291,7 +330,9 @@ export default function GeneralMetrics({
Detectors
-
+
{statsHistory.length != 0 ? (
Detector Inference Speed
@@ -310,6 +351,28 @@ export default function GeneralMetrics({ ) : ( )} + {statsHistory.length != 0 ? ( + <> + {detTempSeries && ( +
+
Detector Temperature
+ {detTempSeries.map((series) => ( + + ))} +
+ )} + + ) : ( + + )} {statsHistory.length != 0 ? (
Detector CPU Usage