From 21abed53c10caa740a70ac71b22bea15cdf2763c Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 25 May 2023 15:33:05 -0600 Subject: [PATCH] Add option for network bandwidth and only calculate if enabled --- frigate/config.py | 1 + frigate/stats.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frigate/config.py b/frigate/config.py index 43a43be0d..5c495e376 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -94,6 +94,7 @@ class TelemetryConfig(FrigateBaseModel): default=["eth", "enp", "eno", "ens", "wl", "lo"], title="Enabled network interfaces for bandwidth calculation.", ) + network_bandwidth: bool = Field(default=False, title="Enable network bandwidth for ffmpeg processes.") version_check: bool = Field(default=True, title="Enable latest version check.") diff --git a/frigate/stats.py b/frigate/stats.py index dd8c4b06d..b8191ec90 100644 --- a/frigate/stats.py +++ b/frigate/stats.py @@ -104,13 +104,15 @@ def get_processing_stats( """Get stats for cpu / gpu.""" async def run_tasks() -> None: - await asyncio.wait( - [ - asyncio.create_task(set_gpu_stats(config, stats, hwaccel_errors)), - asyncio.create_task(set_cpu_stats(stats)), - asyncio.create_task(set_bandwidth_stats(config, stats)), - ] - ) + stats_tasks = [ + asyncio.create_task(set_gpu_stats(config, stats, hwaccel_errors)), + asyncio.create_task(set_cpu_stats(stats)), + ] + + if config.telemetry.network_bandwidth: + stats_tasks.append(asyncio.create_task(set_bandwidth_stats(config, stats))) + + await asyncio.wait(stats_tasks) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop)