From 5fb96c777a9c4faeac44942f3f5a638e9bee5299 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Mon, 15 May 2023 15:39:03 +0300 Subject: [PATCH] Add cmdline information to CPU usage stats in get_cpu_stats() function and display it in the System page's ffmpeg table with a copy-to-clipboard button (#6430) --- frigate/util.py | 4 +++- web/src/routes/System.jsx | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frigate/util.py b/frigate/util.py index d98cee106..a6b4c912a 100755 --- a/frigate/util.py +++ b/frigate/util.py @@ -800,10 +800,11 @@ def get_cpu_stats() -> dict[str, dict]: docker_memlimit = get_docker_memlimit_bytes() / 1024 total_mem = os.sysconf("SC_PAGE_SIZE") * os.sysconf("SC_PHYS_PAGES") / 1024 - for process in psutil.process_iter(["pid", "name", "cpu_percent"]): + for process in psutil.process_iter(["pid", "name", "cpu_percent", "cmdline"]): pid = process.info["pid"] try: cpu_percent = process.info["cpu_percent"] + cmdline = process.info["cmdline"] with open(f"/proc/{pid}/stat", "r") as f: stats = f.readline().split() @@ -837,6 +838,7 @@ def get_cpu_stats() -> dict[str, dict]: "cpu": str(cpu_percent), "cpu_average": str(round(cpu_average_usage, 2)), "mem": f"{mem_pct}", + "cmdline": " ".join(cmdline), } except: continue diff --git a/web/src/routes/System.jsx b/web/src/routes/System.jsx index 7ec238596..b6d78dd54 100644 --- a/web/src/routes/System.jsx +++ b/web/src/routes/System.jsx @@ -347,7 +347,15 @@ export default function System() { - ffmpeg + ffmpeg + + {cameras[camera]['ffmpeg_pid'] || '- '} {cameras[camera]['camera_fps'] || '- '} {cpu_usages[cameras[camera]['ffmpeg_pid']]?.['cpu'] || '- '}%