diff --git a/frigate/stats/util.py b/frigate/stats/util.py index a071dae1f..ee93bb6e6 100644 --- a/frigate/stats/util.py +++ b/frigate/stats/util.py @@ -268,10 +268,13 @@ def stats_snapshot( camera_metrics = stats_tracking["camera_metrics"] stats: dict[str, Any] = {} - total_detection_fps = 0 + total_camera_fps = total_process_fps = total_skipped_fps = total_detection_fps = 0 stats["cameras"] = {} for name, camera_stats in camera_metrics.items(): + total_camera_fps += camera_stats.camera_fps.value + total_process_fps += camera_stats.process_fps.value + total_skipped_fps += camera_stats.skipped_fps.value total_detection_fps += camera_stats.detection_fps.value pid = camera_stats.process_pid.value if camera_stats.process_pid.value else None ffmpeg_pid = camera_stats.ffmpeg_pid.value if camera_stats.ffmpeg_pid else None @@ -305,6 +308,9 @@ def stats_snapshot( # from mypy 0.981 onwards "pid": pid, } + stats["camera_fps"] = round(total_camera_fps, 2) + stats["process_fps"] = round(total_process_fps, 2) + stats["skipped_fps"] = round(total_skipped_fps, 2) stats["detection_fps"] = round(total_detection_fps, 2) stats["embeddings"] = {} diff --git a/frigate/test/http_api/base_http_test.py b/frigate/test/http_api/base_http_test.py index e758a14dc..e0e5fbf03 100644 --- a/frigate/test/http_api/base_http_test.py +++ b/frigate/test/http_api/base_http_test.py @@ -45,6 +45,9 @@ class BaseTestHttp(unittest.TestCase): }, } self.test_stats = { + "camera_fps": 5.0, + "process_fps": 5.0, + "skipped_fps": 0.0, "detection_fps": 13.7, "detectors": { "cpu1": { diff --git a/frigate/test/test_http.py b/frigate/test/test_http.py index ba31b0908..6d60932a5 100644 --- a/frigate/test/test_http.py +++ b/frigate/test/test_http.py @@ -49,6 +49,9 @@ class TestHttp(unittest.TestCase): }, } self.test_stats = { + "camera_fps": 5.0, + "process_fps": 5.0, + "skipped_fps": 0.0, "detection_fps": 13.7, "detectors": { "cpu1": { diff --git a/web/src/types/stats.ts b/web/src/types/stats.ts index 611379be3..a196dff18 100644 --- a/web/src/types/stats.ts +++ b/web/src/types/stats.ts @@ -7,6 +7,9 @@ export interface FrigateStats { npu_usages?: { [npuKey: string]: NpuStats }; processes: { [processKey: string]: ExtraProcessStats }; service: ServiceStats; + camera_fps: number; + process_fps: number; + skipped_fps: number; detection_fps: number; } diff --git a/web/src/views/system/CameraMetrics.tsx b/web/src/views/system/CameraMetrics.tsx index 3f5891265..5c3594e79 100644 --- a/web/src/views/system/CameraMetrics.tsx +++ b/web/src/views/system/CameraMetrics.tsx @@ -97,14 +97,9 @@ export default function CameraMetrics({ return; } - let frames = 0; - Object.values(stats.cameras).forEach( - (camStat) => (frames += camStat.camera_fps), - ); - series["overall_fps"].data.push({ x: statsIdx, - y: Math.round(frames), + y: stats.camera_fps, }); series["overall_dps"].data.push({ @@ -112,14 +107,9 @@ export default function CameraMetrics({ y: stats.detection_fps, }); - let skipped = 0; - Object.values(stats.cameras).forEach( - (camStat) => (skipped += camStat.skipped_fps), - ); - series["overall_skipped_dps"].data.push({ x: statsIdx, - y: skipped, + y: stats.skipped_fps, }); }); return Object.values(series);