Add network bandwidth usage to system table in web UI and improve regex in get_bandwidth_stats function to include frigate detector processes

This commit is contained in:
Sergey Krashevich 2023-05-18 09:05:34 +03:00
parent 5358a104a5
commit 5a0a9bc7b1
No known key found for this signature in database
GPG Key ID: 625171324E7D3856
2 changed files with 3 additions and 1 deletions

View File

@ -864,7 +864,7 @@ def get_bandwidth_stats() -> dict[str, dict]:
for line in lines: for line in lines:
stats = list(filter(lambda a: a != "", line.strip().split("\t"))) stats = list(filter(lambda a: a != "", line.strip().split("\t")))
try: try:
if re.search("(^ffmpeg|\/go2rtc)/([0-9]+)/", stats[0]): if re.search("(^ffmpeg|\/go2rtc|frigate\.detector\.[a-z]+)/([0-9]+)/", stats[0]):
process = stats[0].split("/") process = stats[0].split("/")
usages[process[len(process) - 2]] = { usages[process[len(process) - 2]] = {
"bandwidth": round(float(stats[2]), 1), "bandwidth": round(float(stats[2]), 1),

View File

@ -239,6 +239,7 @@ export default function System() {
<Th>Inference Speed</Th> <Th>Inference Speed</Th>
<Th>CPU %</Th> <Th>CPU %</Th>
<Th>Memory %</Th> <Th>Memory %</Th>
<Th>Network Bandwidth</Th>
</Tr> </Tr>
</Thead> </Thead>
<Tbody> <Tbody>
@ -247,6 +248,7 @@ export default function System() {
<Td>{detectors[detector]['inference_speed']} ms</Td> <Td>{detectors[detector]['inference_speed']} ms</Td>
<Td>{cpu_usages[detectors[detector]['pid']]?.['cpu'] || '- '}%</Td> <Td>{cpu_usages[detectors[detector]['pid']]?.['cpu'] || '- '}%</Td>
<Td>{cpu_usages[detectors[detector]['pid']]?.['mem'] || '- '}%</Td> <Td>{cpu_usages[detectors[detector]['pid']]?.['mem'] || '- '}%</Td>
<Td>{bandwidth_usages[detectors[detector]['pid']]?.['bandwidth'] || '- '}KB/s</Td>
</Tr> </Tr>
</Tbody> </Tbody>
</Table> </Table>