Skip to content

Commit 800c163

Browse files
authored
Merge pull request #11676 from todor-ivanov/bugfix_SmapsParsingError_fix-11667-2
Parse /proc/<pid>/smaps_rollup if present && Reduce string concatenaion operations
2 parents e920d72 + a1ca14d commit 800c163

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/python/WMCore/WMRuntime/Monitors/PerformanceMonitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def __init__(self):
8484

8585
self.pid = None
8686
self.uid = os.getuid()
87-
self.monitorBase = "ps -p %i -o pid,ppid,rss,pcpu,pmem,cmd -ww | grep %i"
88-
self.pssMemoryCommand = "awk '/^Pss/ {pss += $2} END {print pss}' /proc/%i/smaps"
87+
self.monitorBase = "pid=%i; ps -p $pid -o pid,ppid,rss,pcpu,pmem,cmd -ww | grep $pid"
88+
self.pssMemoryCommand = "pid=%i; awk '/^Pss:/ {print $2}' /proc/$pid/smaps_rollup 2>/dev/null || awk '/^Pss:/ {pss += $2} END {print pss}' /proc/$pid/smaps"
8989
self.monitorCommand = None
9090
self.currentStepSpace = None
9191
self.currentStepName = None
@@ -210,7 +210,7 @@ def periodicUpdate(self):
210210

211211
# Now we run the ps monitor command and collate the data
212212
# Gathers RSS, %CPU and %MEM statistics from ps
213-
ps_cmd = self.monitorBase % (stepPID, stepPID)
213+
ps_cmd = self.monitorBase % (stepPID)
214214
stdout, _stderr, _retcode = subprocessAlgos.runCommand(ps_cmd)
215215

216216
ps_output = stdout.split()

0 commit comments

Comments
 (0)