mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-16 18:43:02 +03:00
More accurately label Intel stats
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
"gpuUsage": "GPU Usage",
|
||||
"gpuMemory": "GPU Memory",
|
||||
"gpuEncoder": "GPU Encoder",
|
||||
"gpuCompute": "GPU Compute / Encode",
|
||||
"gpuDecoder": "GPU Decoder",
|
||||
"gpuTemperature": "GPU Temperature",
|
||||
"gpuInfo": {
|
||||
@@ -188,6 +189,7 @@
|
||||
"cameraFfmpeg": "{{camName}} FFmpeg",
|
||||
"cameraCapture": "{{camName}} capture",
|
||||
"cameraDetect": "{{camName}} detect",
|
||||
"cameraGpu": "{{camName}} GPU",
|
||||
"cameraFramesPerSecond": "{{camName}} frames per second",
|
||||
"cameraDetectionsPerSecond": "{{camName}} detections per second",
|
||||
"cameraSkippedDetectionsPerSecond": "{{camName}} skipped detections per second"
|
||||
|
||||
@@ -60,8 +60,10 @@ export type GpuStats = {
|
||||
mem: string;
|
||||
enc?: string;
|
||||
dec?: string;
|
||||
compute?: string;
|
||||
pstate?: string;
|
||||
temp?: number;
|
||||
clients?: { [pid: string]: string };
|
||||
};
|
||||
|
||||
export type NpuStats = {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CameraLineGraph } from "@/components/graph/LineGraph";
|
||||
import CameraInfoDialog from "@/components/overlay/CameraInfoDialog";
|
||||
import { ConnectionQualityIndicator } from "@/components/camera/ConnectionQualityIndicator";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { FrigateConfig } from "@/types/frigateConfig";
|
||||
import { FrigateStats } from "@/types/stats";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -43,7 +44,7 @@ export default function CameraMetrics({
|
||||
[
|
||||
"stats/history",
|
||||
{
|
||||
keys: "cpu_usages,cameras,camera_fps,detection_fps,skipped_fps,service",
|
||||
keys: "cpu_usages,gpu_usages,cameras,camera_fps,detection_fps,skipped_fps,service",
|
||||
},
|
||||
],
|
||||
{
|
||||
@@ -183,6 +184,64 @@ export default function CameraMetrics({
|
||||
return series;
|
||||
}, [config, getCameraName, statsHistory, t]);
|
||||
|
||||
const cameraGpuSeries = useMemo(() => {
|
||||
if (!statsHistory || statsHistory.length == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// Find GPU entry with per-client data
|
||||
const firstGpu = statsHistory.find((s) => s?.gpu_usages);
|
||||
if (!firstGpu?.gpu_usages) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const gpuWithClients = Object.values(firstGpu.gpu_usages).find(
|
||||
(g) => g.clients,
|
||||
);
|
||||
if (!gpuWithClients) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const series: {
|
||||
[cam: string]: {
|
||||
[key: string]: { name: string; data: { x: number; y: string }[] };
|
||||
};
|
||||
} = {};
|
||||
|
||||
statsHistory.forEach((stats, statsIdx) => {
|
||||
if (!stats) {
|
||||
return;
|
||||
}
|
||||
|
||||
const gpuClients = Object.values(stats.gpu_usages || {}).find(
|
||||
(g) => g.clients,
|
||||
)?.clients;
|
||||
|
||||
Object.entries(stats.cameras).forEach(([key, camStats]) => {
|
||||
if (!config?.cameras[key].enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(key in series)) {
|
||||
const camName = getCameraName(key);
|
||||
series[key] = {};
|
||||
series[key]["gpu"] = {
|
||||
name: t("cameras.label.cameraGpu", { camName: camName }),
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
|
||||
const pid = camStats.ffmpeg_pid?.toString();
|
||||
series[key]["gpu"].data.push({
|
||||
x: statsIdx,
|
||||
y: (gpuClients && pid ? gpuClients[pid] : undefined)
|
||||
?.slice(0, -1) ?? "0",
|
||||
});
|
||||
});
|
||||
});
|
||||
return series;
|
||||
}, [config, getCameraName, statsHistory, t]);
|
||||
|
||||
const cameraFpsSeries = useMemo(() => {
|
||||
if (!statsHistory) {
|
||||
return {};
|
||||
@@ -332,7 +391,11 @@ export default function CameraMetrics({
|
||||
</div>
|
||||
<div
|
||||
key={camera.name}
|
||||
className="grid gap-2 sm:grid-cols-2"
|
||||
className={cn(
|
||||
"grid gap-2 sm:grid-cols-2",
|
||||
Object.keys(cameraGpuSeries).length > 0 &&
|
||||
"lg:grid-cols-3",
|
||||
)}
|
||||
>
|
||||
{Object.keys(cameraCpuSeries).includes(camera.name) ? (
|
||||
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
|
||||
@@ -350,6 +413,20 @@ export default function CameraMetrics({
|
||||
) : (
|
||||
<Skeleton className="aspect-video size-full" />
|
||||
)}
|
||||
{Object.keys(cameraGpuSeries).includes(camera.name) && (
|
||||
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
|
||||
<div className="mb-5">GPU</div>
|
||||
<CameraLineGraph
|
||||
graphId={`${camera.name}-gpu`}
|
||||
unit="%"
|
||||
dataLabels={["gpu"]}
|
||||
updateTimes={updateTimes}
|
||||
data={Object.values(
|
||||
cameraGpuSeries[camera.name] || {},
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{Object.keys(cameraFpsSeries).includes(camera.name) ? (
|
||||
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
|
||||
<div className="mb-5">
|
||||
|
||||
@@ -334,6 +334,43 @@ export default function GeneralMetrics({
|
||||
return Object.keys(series).length > 0 ? Object.values(series) : undefined;
|
||||
}, [statsHistory]);
|
||||
|
||||
const gpuComputeSeries = useMemo(() => {
|
||||
if (!statsHistory) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const series: {
|
||||
[key: string]: { name: string; data: { x: number; y: string }[] };
|
||||
} = {};
|
||||
let hasValidGpu = false;
|
||||
|
||||
statsHistory.forEach((stats, statsIdx) => {
|
||||
if (!stats) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.entries(stats.gpu_usages || {}).forEach(([key, stats]) => {
|
||||
if (!(key in series)) {
|
||||
series[key] = { name: key, data: [] };
|
||||
}
|
||||
|
||||
if (stats.compute) {
|
||||
hasValidGpu = true;
|
||||
series[key].data.push({
|
||||
x: statsIdx + 1,
|
||||
y: stats.compute.slice(0, -1),
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (!hasValidGpu) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Object.keys(series).length > 0 ? Object.values(series) : undefined;
|
||||
}, [statsHistory]);
|
||||
|
||||
const gpuDecSeries = useMemo(() => {
|
||||
if (!statsHistory) {
|
||||
return [];
|
||||
@@ -742,8 +779,9 @@ export default function GeneralMetrics({
|
||||
className={cn(
|
||||
"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-2",
|
||||
gpuTempSeries?.length && "md:grid-cols-3",
|
||||
gpuEncSeries?.length && "xl:grid-cols-4",
|
||||
gpuEncSeries?.length &&
|
||||
(gpuEncSeries?.length || gpuComputeSeries?.length) &&
|
||||
"xl:grid-cols-4",
|
||||
(gpuEncSeries?.length || gpuComputeSeries?.length) &&
|
||||
gpuTempSeries?.length &&
|
||||
"3xl:grid-cols-5",
|
||||
)}
|
||||
@@ -856,6 +894,30 @@ export default function GeneralMetrics({
|
||||
) : (
|
||||
<Skeleton className="aspect-video w-full" />
|
||||
)}
|
||||
{statsHistory.length != 0 ? (
|
||||
<>
|
||||
{gpuComputeSeries && gpuComputeSeries?.length != 0 && (
|
||||
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
|
||||
<div className="mb-5">
|
||||
{t("general.hardwareInfo.gpuCompute")}
|
||||
</div>
|
||||
{gpuComputeSeries.map((series) => (
|
||||
<ThresholdBarGraph
|
||||
key={series.name}
|
||||
graphId={`${series.name}-compute`}
|
||||
unit="%"
|
||||
name={series.name}
|
||||
threshold={GPUMemThreshold}
|
||||
updateTimes={updateTimes}
|
||||
data={[series]}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Skeleton className="aspect-video w-full" />
|
||||
)}
|
||||
{statsHistory.length != 0 ? (
|
||||
<>
|
||||
{gpuDecSeries && gpuDecSeries?.length != 0 && (
|
||||
|
||||
Reference in New Issue
Block a user