NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Option to enable / disable stats that require external processes (#6615)
Nicolas Mowen32569842d34a
diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.mdindex 1644903a13..980d14465d 100644--- a/docs/docs/configuration/index.md+++ b/docs/docs/configuration/index.md@@ -568,6 +568,14 @@ telemetry:- ens- wl- lo+ # Optional: Configure system stats+ stats:+ # Enable AMD GPU stats (default: shown below)+ amd_gpu_stats: True+ # Enable Intel GPU stats (default: shown below)+ intel_gpu_stats: True+ # Enable network bandwidth stats monitoring for camera ffmpeg processes, go2rtc, and object detectors. (default: shown below)+ network_bandwidth: False# Optional: Enable the latest version outbound check (default: shown below)# NOTE: If you use the HomeAssistant integration, disabling this will prevent it from reporting new versionsversion_check: Truediff --git a/frigate/config.py b/frigate/config.pyindex 58545e27cf..156a755c50 100644--- a/frigate/config.py+++ b/frigate/config.py@@ -89,11 +89,22 @@ class UIConfig(FrigateBaseModel):)+class StatsConfig(FrigateBaseModel):+ amd_gpu_stats: bool = Field(default=True, title="Enable AMD GPU stats.")+ intel_gpu_stats: bool = Field(default=True, title="Enable Intel GPU stats.")+ network_bandwidth: bool = Field(+ default=False, title="Enable network bandwidth for ffmpeg processes."+ )++class TelemetryConfig(FrigateBaseModel):network_interfaces: List[str] = Field(default=["eth", "enp", "eno", "ens", "wl", "lo"],title="Enabled network interfaces for bandwidth calculation.",)+ stats: StatsConfig = Field(+ default_factory=StatsConfig, title="System Stats Configuration"+ )version_check: bool = Field(default=True, title="Enable latest version check.")diff --git a/frigate/stats.py b/frigate/stats.pyindex dd8c4b06d9..246f74bf1c 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.stats.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)@@ -179,6 +181,9 @@ async def set_gpu_stats(stats["nvidia-gpu"] = {"gpu": -1, "mem": -1}hwaccel_errors.append(args)elif "qsv" in args:+ if not config.telemetry.stats.intel_gpu_stats:+ continue+# intel QSV GPUintel_usage = get_intel_gpu_stats()@@ -191,6 +196,9 @@ async def set_gpu_stats(driver = os.environ.get(DRIVER_ENV_VAR)if driver == DRIVER_AMD:+ if not config.telemetry.stats.amd_gpu_stats:+ continue+# AMD VAAPI GPUamd_usage = get_amd_gpu_stats()@@ -200,6 +208,9 @@ async def set_gpu_stats(stats["amd-vaapi"] = {"gpu": -1, "mem": -1}hwaccel_errors.append(args)else:+ if not config.telemetry.stats.intel_gpu_stats:+ continue+# intel VAAPI GPUintel_usage = get_intel_gpu_stats()diff --git a/web/src/routes/System.jsx b/web/src/routes/System.jsxindex bf4c57c453..82c8d619dd 100644--- a/web/src/routes/System.jsx+++ b/web/src/routes/System.jsx@@ -96,7 +96,8 @@ export default function System() {System <span className="text-sm">{service.version}</span></Heading>{config && (- <span class="p-1">go2rtc {go2rtc && ( `${go2rtc.version} ` ) }+ <span class="p-1">+ go2rtc {go2rtc && `${go2rtc.version} `}<LinkclassName="text-blue-500 hover:underline"target="_blank"@@ -239,7 +240,7 @@ export default function System() {<Th>Inference Speed</Th><Th>CPU %</Th><Th>Memory %</Th>- <Th>Network Bandwidth</Th>+ {config.telemetry.network_bandwidth && <Th>Network Bandwidth</Th>}</Tr></Thead><Tbody>@@ -248,7 +249,9 @@ export default function System() {<Td>{detectors[detector]['inference_speed']} ms</Td><Td>{cpu_usages[detectors[detector]['pid']]?.['cpu'] || '- '}%</Td><Td>{cpu_usages[detectors[detector]['pid']]?.['mem'] || '- '}%</Td>- <Td>{bandwidth_usages[detectors[detector]['pid']]?.['bandwidth'] || '- '}KB/s</Td>+ {config.telemetry.network_bandwidth && (+ <Td>{bandwidth_usages[detectors[detector]['pid']]?.['bandwidth'] || '- '}KB/s</Td>+ )}</Tr></Tbody></Table>@@ -346,25 +349,30 @@ export default function System() {<Th>FPS</Th><Th>CPU %</Th><Th>Memory %</Th>- <Th>Network Bandwidth</Th>+ {config.telemetry.network_bandwidth && <Th>Network Bandwidth</Th>}</Tr></Thead><Tbody><Tr key="ffmpeg" index="0">- <Td>ffmpeg+ <Td>+ ffmpeg<ButtonclassName="rounded-full"type="text"color="gray"aria-label={cpu_usages[cameras[camera]['ffmpeg_pid']]?.['cmdline']}onClick={() => copy(cpu_usages[cameras[camera]['ffmpeg_pid']]?.['cmdline'])}- ><About className="w-3" /></Button>+ >+ <About className="w-3" />+ </Button></Td><Td>{cameras[camera]['ffmpeg_pid'] || '- '}</Td><Td>{cameras[camera]['camera_fps'] || '- '}</Td><Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]?.['cpu'] || '- '}%</Td><Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]?.['mem'] || '- '}%</Td>- <Td>{bandwidth_usages[cameras[camera]['ffmpeg_pid']]?.['bandwidth'] || '- '}KB/s</Td>+ {config.telemetry.network_bandwidth && (+ <Td>{bandwidth_usages[cameras[camera]['ffmpeg_pid']]?.['bandwidth'] || '- '}KB/s</Td>+ )}</Tr><Tr key="capture" index="1"><Td>Capture</Td>@@ -372,7 +380,7 @@ export default function System() {<Td>{cameras[camera]['process_fps'] || '- '}</Td><Td>{cpu_usages[cameras[camera]['capture_pid']]?.['cpu'] || '- '}%</Td><Td>{cpu_usages[cameras[camera]['capture_pid']]?.['mem'] || '- '}%</Td>- <Td>-</Td>+ {config.telemetry.network_bandwidth && <Td>-</Td>}</Tr><Tr key="detect" index="2"><Td>Detect</Td>@@ -393,7 +401,7 @@ export default function System() {<Td>{cpu_usages[cameras[camera]['pid']]?.['cpu'] || '- '}%</Td><Td>{cpu_usages[cameras[camera]['pid']]?.['mem'] || '- '}%</Td>- <Td>-</Td>+ {config.telemetry.network_bandwidth && <Td>-</Td>}</Tr></Tbody></Table>@@ -430,7 +438,7 @@ export default function System() {<Th>CPU %</Th><Th>Avg CPU %</Th><Th>Memory %</Th>- <Th>Network Bandwidth</Th>+ {config.telemetry.network_bandwidth && <Th>Network Bandwidth</Th>}</Tr></Thead><Tbody>@@ -439,7 +447,9 @@ export default function System() {<Td>{cpu_usages[processes[process]['pid']]?.['cpu'] || '- '}%</Td><Td>{cpu_usages[processes[process]['pid']]?.['cpu_average'] || '- '}%</Td><Td>{cpu_usages[processes[process]['pid']]?.['mem'] || '- '}%</Td>- <Td>{bandwidth_usages[processes[process]['pid']]?.['bandwidth'] || '- '}KB/s</Td>+ {config.telemetry.network_bandwidth && (+ <Td>{bandwidth_usages[processes[process]['pid']]?.['bandwidth'] || '- '}KB/s</Td>+ )}</Tr></Tbody></Table>