Skip to content

Commit 3ba1ecd

Browse files
committed
fix: RAM percent and Usage per container
1 parent 603a3b6 commit 3ba1ecd

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/aind_ephys_portal/ephys_monitor_app.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,27 @@ def refresh_log_tabs():
227227
# --- Process table (htop-like) ---
228228
def get_process_table():
229229
"""Collect per-process info into a DataFrame."""
230+
container_total = get_container_total_memory()
230231
rows = []
231-
for proc in psutil.process_iter(["pid", "name", "cpu_percent", "memory_percent", "status"]):
232+
for proc in psutil.process_iter(["pid", "name", "cpu_percent", "status"]):
232233
try:
233234
info = proc.info
235+
rss = proc.memory_info().rss
236+
rss_gb = rss / (1024**3)
237+
mem_pct = rss / container_total * 100 if container_total else 0.0
234238
rows.append(
235239
{
236240
"PID": info["pid"],
237241
"Name": info["name"] or "",
238242
"CPU %": round(info["cpu_percent"] or 0.0, 1),
239-
"Memory %": round(info["memory_percent"] or 0.0, 1),
243+
"RAM (GB)": round(rss_gb, 2),
244+
"Memory %": round(mem_pct, 1),
240245
"Status": info["status"] or "",
241246
}
242247
)
243248
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
244249
continue
245-
df = pd.DataFrame(rows, columns=["PID", "Name", "CPU %", "Memory %", "Status"])
250+
df = pd.DataFrame(rows, columns=["PID", "Name", "CPU %", "RAM (GB)", "Memory %", "Status"])
246251
return df.sort_values("CPU %", ascending=False).reset_index(drop=True)
247252

248253

0 commit comments

Comments
 (0)