mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 21:25:24 +03:00
fix stats from crashing the ui
This commit is contained in:
parent
298b9fc13f
commit
9fbb516c27
@ -36,21 +36,33 @@ export default function useStats(stats: FrigateStats | undefined) {
|
|||||||
|
|
||||||
// check camera cpu usages
|
// check camera cpu usages
|
||||||
Object.entries(stats["cameras"]).forEach(([name, cam]) => {
|
Object.entries(stats["cameras"]).forEach(([name, cam]) => {
|
||||||
const ffmpegAvg = parseFloat(
|
if (
|
||||||
stats["cpu_usages"][cam["ffmpeg_pid"]].cpu_average,
|
stats["cpu_usages"][cam["ffmpeg_pid"]] &&
|
||||||
);
|
stats["cpu_usages"][cam["pid"]]
|
||||||
const detectAvg = parseFloat(stats["cpu_usages"][cam["pid"]].cpu_average);
|
) {
|
||||||
|
const ffmpegAvg = parseFloat(
|
||||||
|
stats["cpu_usages"][cam["ffmpeg_pid"]].cpu_average,
|
||||||
|
);
|
||||||
|
const detectAvg = parseFloat(
|
||||||
|
stats["cpu_usages"][cam["pid"]].cpu_average,
|
||||||
|
);
|
||||||
|
|
||||||
if (!isNaN(ffmpegAvg) && ffmpegAvg >= 20.0) {
|
if (!isNaN(ffmpegAvg) && ffmpegAvg >= 20.0) {
|
||||||
problems.push({
|
problems.push({
|
||||||
text: `${name.replaceAll("_", " ")} has high FFMPEG CPU usage (${ffmpegAvg}%)`,
|
text: `${name.replaceAll("_", " ")} has high FFMPEG CPU usage (${ffmpegAvg}%)`,
|
||||||
color: "text-danger",
|
color: "text-danger",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNaN(detectAvg) && detectAvg >= 40.0) {
|
if (!isNaN(detectAvg) && detectAvg >= 40.0) {
|
||||||
|
problems.push({
|
||||||
|
text: `${name.replaceAll("_", " ")} has high detect CPU usage (${detectAvg}%)`,
|
||||||
|
color: "text-danger",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
problems.push({
|
problems.push({
|
||||||
text: `${name.replaceAll("_", " ")} has high detect CPU usage (${detectAvg}%)`,
|
text: `${name.replaceAll("_", " ")} is offline.`,
|
||||||
color: "text-danger",
|
color: "text-danger",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user