check for invalid value

This commit is contained in:
Josh Hawkins 2024-04-01 08:56:31 -05:00
parent 3098762254
commit d96ee6dbf1

View File

@ -36,33 +36,23 @@ 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]) => {
if ( const ffmpegAvg = parseFloat(
stats["cpu_usages"][cam["ffmpeg_pid"]] && stats["cpu_usages"][cam["ffmpeg_pid"]]?.cpu_average,
stats["cpu_usages"][cam["pid"]] );
) { const detectAvg = parseFloat(
const ffmpegAvg = parseFloat( stats["cpu_usages"][cam["pid"]]?.cpu_average,
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({
text: `${name.replaceAll("_", " ")} has high FFMPEG CPU usage (${ffmpegAvg}%)`,
color: "text-danger",
});
}
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("_", " ")} is offline.`, text: `${name.replaceAll("_", " ")} has high FFMPEG CPU usage (${ffmpegAvg}%)`,
color: "text-danger",
});
}
if (!isNaN(detectAvg) && detectAvg >= 40.0) {
problems.push({
text: `${name.replaceAll("_", " ")} has high detect CPU usage (${detectAvg}%)`,
color: "text-danger", color: "text-danger",
}); });
} }