From 6d0c2ec5c877a50bd1c46da768f9cb073add99e9 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Thu, 18 May 2023 14:40:24 +0300 Subject: [PATCH] Add go2rtc & remote detectors network bandwidth usage to System table (#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:( --- frigate/util.py | 8 +++++--- web/src/routes/System.jsx | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/frigate/util.py b/frigate/util.py index f82476ebc..47b7b4323 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -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 diff --git a/web/src/routes/System.jsx b/web/src/routes/System.jsx index 8d5c4ef80..012d1be03 100644 --- a/web/src/routes/System.jsx +++ b/web/src/routes/System.jsx @@ -239,6 +239,7 @@ export default function System() { Inference Speed CPU % Memory % + Network Bandwidth @@ -247,6 +248,7 @@ export default function System() { {detectors[detector]['inference_speed']} ms {cpu_usages[detectors[detector]['pid']]?.['cpu'] || '- '}% {cpu_usages[detectors[detector]['pid']]?.['mem'] || '- '}% + {bandwidth_usages[detectors[detector]['pid']]?.['bandwidth'] || '- '}KB/s @@ -428,6 +430,7 @@ export default function System() { CPU % Avg CPU % Memory % + Network Bandwidth @@ -436,6 +439,7 @@ export default function System() { {cpu_usages[processes[process]['pid']]?.['cpu'] || '- '}% {cpu_usages[processes[process]['pid']]?.['cpu_average'] || '- '}% {cpu_usages[processes[process]['pid']]?.['mem'] || '- '}% + {bandwidth_usages[processes[process]['pid']]?.['bandwidth'] || '- '}KB/s