Add fps to camera metrics

This commit is contained in:
Nick Mowen 2022-11-09 14:47:13 -07:00
parent 1ccc9bd6b7
commit 84aa7149a6
2 changed files with 73 additions and 68 deletions

View File

@ -91,7 +91,9 @@ def stats_snapshot(stats_tracking: StatsTrackingTypes) -> dict[str, Any]:
for name, camera_stats in camera_metrics.items(): for name, camera_stats in camera_metrics.items():
total_detection_fps += camera_stats["detection_fps"].value total_detection_fps += camera_stats["detection_fps"].value
pid = camera_stats["process"].pid if camera_stats["process"] else None pid = camera_stats["process"].pid if camera_stats["process"] else None
ffmpeg_pid = camera_stats["ffmpeg_pid"].value if camera_stats["ffmpeg_pid"] else None ffmpeg_pid = (
camera_stats["ffmpeg_pid"].value if camera_stats["ffmpeg_pid"] else None
)
cpid = ( cpid = (
camera_stats["capture_process"].pid camera_stats["capture_process"].pid
if camera_stats["capture_process"] if camera_stats["capture_process"]

View File

@ -57,11 +57,14 @@ export default function Debug() {
</div> </div>
) : ( ) : (
<Fragment> <Fragment>
<Heading>Detectors</Heading>
<div data-testid="detectors" className="min-w-0 overflow-auto"> <div data-testid="detectors" className="min-w-0 overflow-auto">
{detectorNames.map((name) => (
<div className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow p-4 m-2">
<div className="text-lg flex justify-between">{name}</div>
<Table className="w-full"> <Table className="w-full">
<Thead> <Thead>
<Tr> <Tr>
<Th>detector</Th>
{detectorDataKeys.map((name) => ( {detectorDataKeys.map((name) => (
<Th key={name}>{name.replace('_', ' ')}</Th> <Th key={name}>{name.replace('_', ' ')}</Th>
))} ))}
@ -70,7 +73,6 @@ export default function Debug() {
<Tbody> <Tbody>
{detectorNames.map((detector, i) => ( {detectorNames.map((detector, i) => (
<Tr key={i} index={i}> <Tr key={i} index={i}>
<Td>{detector}</Td>
{detectorDataKeys.map((name) => ( {detectorDataKeys.map((name) => (
<Td key={`${name}-${detector}`}>{detectors[detector][name]}</Td> <Td key={`${name}-${detector}`}>{detectors[detector][name]}</Td>
))} ))}
@ -79,56 +81,57 @@ export default function Debug() {
</Tbody> </Tbody>
</Table> </Table>
</div> </div>
))}
<Heading>
Cameras
</Heading>
<div data-testid="cameras" className="min-w-0 overflow-auto">
{cameraNames.map((camera, i) => (
<div className='dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow p-4 m-2'>
<div className='text-lg flex justify-between'>
<Link href={`/cameras/${camera}`}>{camera.replaceAll('_', ' ')}</Link>
<Button onClick={(e) => onCopyFfprobe(camera, e)}>
copy ffprobe
</Button>
</div> </div>
<div className='p-4'>
<Table className='w-full'> <Heading>Cameras</Heading>
<div data-testid="cameras" className="min-w-0 overflow-auto">
{cameraNames.map((camera, i) => (
<div className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow p-4 m-2">
<div className="text-lg flex justify-between">
<Link href={`/cameras/${camera}`}>{camera.replaceAll('_', ' ')}</Link>
<Button onClick={(e) => onCopyFfprobe(camera, e)}>copy ffprobe</Button>
</div>
<div className="p-4">
<Table className="w-full">
<Thead> <Thead>
<Tr> <Tr>
<Th>Processes</Th> <Th>Processes</Th>
<Th>Process ID</Th> <Th>Process ID</Th>
<Th>fps</Th>
<Th>Cpu %</Th> <Th>Cpu %</Th>
<Th>Memory %</Th> <Th>Memory %</Th>
</Tr> </Tr>
</Thead> </Thead>
<Tbody> <Tbody>
<Tr key='capture' index='0'> <Tr key="capture" index="0">
<Td>Capture</Td> <Td>Capture</Td>
<Td>{cameras[camera]['capture_pid']}</Td> <Td>{cameras[camera]['capture_pid']}</Td>
<Td>{cameras[camera]['process_fps']}</Td>
<Td>{cpu_usages[cameras[camera]['capture_pid']]['cpu']}%</Td> <Td>{cpu_usages[cameras[camera]['capture_pid']]['cpu']}%</Td>
<Td>{cpu_usages[cameras[camera]['capture_pid']]['mem']}%</Td> <Td>{cpu_usages[cameras[camera]['capture_pid']]['mem']}%</Td>
</Tr> </Tr>
<Tr key='detect' index='1'> <Tr key="detect" index="1">
<Td>Detect</Td> <Td>Detect</Td>
<Td>{cameras[camera]['pid']}</Td> <Td>{cameras[camera]['pid']}</Td>
<Td>
{cameras[camera]['detection_fps']} ({cameras[camera]['skipped_fps']} skipped)
</Td>
<Td>{cpu_usages[cameras[camera]['pid']]['cpu']}%</Td> <Td>{cpu_usages[cameras[camera]['pid']]['cpu']}%</Td>
<Td>{cpu_usages[cameras[camera]['pid']]['cpu']}%</Td> <Td>{cpu_usages[cameras[camera]['pid']]['cpu']}%</Td>
</Tr> </Tr>
<Tr key='ffmpeg' index='2'> <Tr key="ffmpeg" index="2">
<Td>ffmpeg</Td> <Td>ffmpeg</Td>
<Td>{cameras[camera]['ffmpeg_pid']}</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']]['cpu']}%</Td>
<Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]['cpu']}%</Td> <Td>{cpu_usages[cameras[camera]['ffmpeg_pid']]['cpu']}%</Td>
</Tr> </Tr>
</Tbody> </Tbody>
</Table> </Table>
</div> </div>
</div> </div>
))} ))}
</div> </div>
<p>Debug stats update automatically every {config.mqtt.stats_interval} seconds.</p> <p>Debug stats update automatically every {config.mqtt.stats_interval} seconds.</p>