From 44e7b0b2cf7630e1d223a8085d862d0ffbc1727d Mon Sep 17 00:00:00 2001 From: Dave Pedu Date: Sat, 5 Dec 2015 18:09:34 -0800 Subject: [PATCH] fix process names with spaces breaking column count --- pymonitor/monitors/procs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pymonitor/monitors/procs.py b/pymonitor/monitors/procs.py index 4839caa..a997c06 100644 --- a/pymonitor/monitors/procs.py +++ b/pymonitor/monitors/procs.py @@ -4,6 +4,7 @@ import re KTHREADD_PID = 2 PAT_UID = re.compile(r'Uid:\s+(?P[0-9]+)\s') PAT_GID = re.compile(r'Gid:\s+(?P[0-9]+)\s') +PAT_REMOVE_PROC_SPACES = re.compile(r'(\([^\)]+\))') def procs(): @@ -36,7 +37,10 @@ def procs(): with open(f, "r") as statfile: with open(f+"us", "r") as statusfile: # Read stat info - stat = statfile.read().strip().split(" ") + stat = statfile.read().strip() + # Fix spaces in process names + stat = PAT_REMOVE_PROC_SPACES.sub("PROCNAME", stat) + stat = stat.split(" ") # Read uid/gid from status status = statusfile.read()