From b4eac11cbd32b7e471f1fe31e085b486a235705d Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 27 Feb 2026 05:53:26 +0100 Subject: [PATCH] Clean up trailing whitespaces in cpu stats process cmdline (#22089) The psutil library reads the process commandline as by opening /proc/pid/cmdline which returns a buffer that is larger than just the program cmdline due to rounded memory allocation sizes. That means that if the library does not detect a Null-terminated string it keeps appending empty strings which add up as whitespaces when joined. --- frigate/util/services.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frigate/util/services.py b/frigate/util/services.py index 19ec4efdf..f1eedb01e 100644 --- a/frigate/util/services.py +++ b/frigate/util/services.py @@ -121,7 +121,7 @@ def get_cpu_stats() -> dict[str, dict]: pid = str(process.info["pid"]) try: cpu_percent = process.info["cpu_percent"] - cmdline = process.info["cmdline"] + cmdline = " ".join(process.info["cmdline"]).rstrip() with open(f"/proc/{pid}/stat", "r") as f: stats = f.readline().split() @@ -155,7 +155,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": clean_camera_user_pass(" ".join(cmdline)), + "cmdline": clean_camera_user_pass(cmdline), } except Exception: continue