示例#1
0
文件: memory.py 项目: jmoiron/kokuen
 def ps_fallback_usage(self):
     """Memory usage for the given PID using ps instead of proc."""
     p = Popen(['ps', 'u', '-p', str(self.pid)], stdout=PIPE)
     output = p.stdout.read().split('\n')
     output = filter(None, output)
     process_line = output[-1].split()
     vsize_in_kb = process_line[5] + ' kB'
     return to_bytes(vsize_in_kb)
示例#2
0
 def ps_fallback_usage(self):
     """Memory usage for the given PID using ps instead of proc."""
     p = Popen(['ps', 'u', '-p', str(self.pid)], stdout=PIPE)
     output = p.stdout.read().split('\n')
     output = filter(None, output)
     process_line = output[-1].split()
     vsize_in_kb = process_line[5] + ' kB'
     return to_bytes(vsize_in_kb)
示例#3
0
文件: memory.py 项目: jmoiron/kokuen
 def proc_usage(self):
     """Memory usage for given PID."""
     try:
         with open(self.procpath) as f:
             content = f.read()
         size = self.matcher.search(content).groups()[0]
         return to_bytes(size)
     except:
         return self.ps_fallback_usage()
示例#4
0
 def proc_usage(self):
     """Memory usage for given PID."""
     try:
         with open(self.procpath) as f:
             content = f.read()
         size = self.matcher.search(content).groups()[0]
         return to_bytes(size)
     except:
         return self.ps_fallback_usage()