From 580727504e92b794a497d1c2d674651b5d61b88a Mon Sep 17 00:00:00 2001 From: Nicolo Magini Date: Mon, 7 Sep 2015 15:52:46 +0200 Subject: [PATCH] Use ps instead of pmap to get memory usage of file2DS process (fixes incorrect pmap memory repoting introduced with kernel version 2.6.32-573.3.1.el6.x86_64) --- .../popdb.xrootd/file2ds/lib/fileToDataSetAssociation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DataPopularity/popdb.xrootd/file2ds/lib/fileToDataSetAssociation.py b/DataPopularity/popdb.xrootd/file2ds/lib/fileToDataSetAssociation.py index ee84e81..ee38ff0 100644 --- a/DataPopularity/popdb.xrootd/file2ds/lib/fileToDataSetAssociation.py +++ b/DataPopularity/popdb.xrootd/file2ds/lib/fileToDataSetAssociation.py @@ -516,13 +516,13 @@ def reset(self): self.resetCursor() def getProcessMemory(self, pid): - ''' Using pmap to report memory map of a process ''' + ''' Using ps to report memory usage of a process ''' - process = subprocess.Popen('pmap -x %s | tail -1' % pid, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE) + process = subprocess.Popen('ps --no-heading -o vsize -p %s' % pid, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE) process_tuple = process.communicate() memory = 0 if process_tuple[1] == '': - memory = int(process_tuple[0].split()[2]) + memory = int(process_tuple[0]) self.logger.info('The memory used by the process with pid %s is %s' % (pid, memory) ) return memory