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