mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Option to enable / disable stats that require external processes (#6615)
* Add option for network bandwidth and only calculate if enabled * Don't show network bandwidth in system stats page if not enabled * Formatting * Hide other rows as well * Add docs * Add config options for AMD and Intel GPU stats * Fix stats access * Update docs * Use correct bool syntax Co-authored-by: Blake Blackshear <blakeb@blakeshome.com> --------- Co-authored-by: Blake Blackshear <blakeb@blakeshome.com>
This commit is contained in:
parent
5c27cb7e9b
commit
32569842d3
@ -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 versions
|
||||
version_check: True
|
||||
|
@ -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.")
|
||||
|
||||
|
||||
|
@ -104,13 +104,15 @@ def get_processing_stats(
|
||||
"""Get stats for cpu / gpu."""
|
||||
|
||||
async def run_tasks() -> None:
|
||||
await asyncio.wait(
|
||||
[
|
||||
stats_tasks = [
|
||||
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)),
|
||||
]
|
||||
)
|
||||
|
||||
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 GPU
|
||||
intel_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 GPU
|
||||
amd_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 GPU
|
||||
intel_usage = get_intel_gpu_stats()
|
||||
|
||||
|
@ -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} `}
|
||||
<Link
|
||||
className="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>
|
||||
{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
|
||||
<Button
|
||||
className="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>
|
||||
{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>
|
||||
{config.telemetry.network_bandwidth && (
|
||||
<Td>{bandwidth_usages[processes[process]['pid']]?.['bandwidth'] || '- '}KB/s</Td>
|
||||
)}
|
||||
</Tr>
|
||||
</Tbody>
|
||||
</Table>
|
||||
|
Loading…
Reference in New Issue
Block a user