Skip to content

Commit

Permalink
Add go2rtc & remote detectors network bandwidth usage to System table (
Browse files Browse the repository at this point in the history
…#6526)

* Add network bandwidth usage to System table display in System.jsx and update get_bandwidth_stats function in util.py to include go2rtc processes

* black...

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

* black...

* Update bandwidth calculation to include both incoming and outgoing traffic

* black:(
  • Loading branch information
skrashevich committed May 18, 2023
1 parent 17e8a46 commit 6d0c2ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frigate/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,12 @@ def get_bandwidth_stats() -> dict[str, dict]:
for line in lines:
stats = list(filter(lambda a: a != "", line.strip().split("\t")))
try:
if re.search("^ffmpeg/([0-9]+)/", stats[0]):
if re.search(
"(^ffmpeg|\/go2rtc|frigate\.detector\.[a-z]+)/([0-9]+)/", stats[0]
):
process = stats[0].split("/")
usages[process[1]] = {
"bandwidth": round(float(stats[2]), 1),
usages[process[len(process) - 2]] = {
"bandwidth": round(float(stats[1]) + float(stats[2]), 1),
}
except:
continue
Expand Down
4 changes: 4 additions & 0 deletions web/src/routes/System.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export default function System() {
<Th>Inference Speed</Th>
<Th>CPU %</Th>
<Th>Memory %</Th>
<Th>Network Bandwidth</Th>
</Tr>
</Thead>
<Tbody>
Expand All @@ -247,6 +248,7 @@ 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>
<Td>{bandwidth_usages[detectors[detector]['pid']]?.['bandwidth'] || '- '}KB/s</Td>
</Tr>
</Tbody>
</Table>
Expand Down Expand Up @@ -428,6 +430,7 @@ export default function System() {
<Th>CPU %</Th>
<Th>Avg CPU %</Th>
<Th>Memory %</Th>
<Th>Network Bandwidth</Th>
</Tr>
</Thead>
<Tbody>
Expand All @@ -436,6 +439,7 @@ 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>
<Td>{bandwidth_usages[processes[process]['pid']]?.['bandwidth'] || '- '}KB/s</Td>
</Tr>
</Tbody>
</Table>
Expand Down

0 comments on commit 6d0c2ec

Please sign in to comment.