import { h, Fragment } from 'preact'; import ActivityIndicator from '../components/ActivityIndicator'; import Button from '../components/Button'; import Heading from '../components/Heading'; import Link from '../components/Link'; import { useMqtt } from '../api/mqtt'; import useSWR from 'swr'; import axios from 'axios'; import { Table, Tbody, Thead, Tr, Th, Td } from '../components/Table'; import { useCallback, useState } from 'preact/hooks'; import Dialog from '../components/Dialog'; const emptyObject = Object.freeze({}); export default function Debug() { const [state, setState] = useState({ showFfprobe: false, ffprobe: '' }); const { data: config } = useSWR('config'); const { value: { payload: stats }, } = useMqtt('stats'); const { data: initialStats } = useSWR('stats'); const { cpu_usages, detectors, service = {}, detection_fps: _, ...cameras } = stats || initialStats || emptyObject; const detectorNames = Object.keys(detectors || emptyObject); const cameraNames = Object.keys(cameras || emptyObject); const handleCopyConfig = useCallback(() => { async function copy() { await window.navigator.clipboard.writeText(JSON.stringify(config, null, 2)); } copy(); }, [config]); const onHandleFfprobe = async (camera, e) => { if (e) { e.stopPropagation(); } setState({ ...state, showFfprobe: true }); let paths = ''; config.cameras[camera].ffmpeg.inputs.forEach((input) => { if (paths) { paths += ','; paths += input.path; } else { paths = input.path; } }); const response = await axios.get('ffprobe', { params: { paths, }, }); if (response.status === 200) { setState({ showFfprobe: true, ffprobe: JSON.stringify(response.data, null, 2) }); } else { setState({ ...state, ffprobe: 'There was an error getting the ffprobe output.' }); } }; const onCopyFfprobe = async () => { await window.navigator.clipboard.writeText(JSON.stringify(state.ffprobe, null, 2)); setState({ ...state, ffprobe: '', showFfprobe: false }); }; return (
P-ID | Detection Start | Inference Speed |
---|---|---|
{detectors[detector]['pid']} | {detectors[detector]['detection_start']} | {detectors[detector]['inference_speed']} |
Process | P-ID | fps | Cpu % | Memory % |
---|---|---|---|---|
Capture | {cameras[camera]['capture_pid']} | {cameras[camera]['process_fps']} | {cpu_usages[cameras[camera]['capture_pid']]['cpu']}% | {cpu_usages[cameras[camera]['capture_pid']]['mem']}% |
Detect | {cameras[camera]['pid']} | {cameras[camera]['detection_fps']} ({cameras[camera]['skipped_fps']} skipped) | {cpu_usages[cameras[camera]['pid']]['cpu']}% | {cpu_usages[cameras[camera]['pid']]['cpu']}% |
ffmpeg | {cameras[camera]['ffmpeg_pid']} | {cameras[camera]['camera_fps']} | {cpu_usages[cameras[camera]['ffmpeg_pid']]['cpu']}% | {cpu_usages[cameras[camera]['ffmpeg_pid']]['cpu']}% |
Debug stats update automatically every {config.mqtt.stats_interval} seconds.
{JSON.stringify(config, null, 2)}