MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / get_process_info_by_pid

Method get_process_info_by_pid

class/projectModel/pythonModel.py:3387–3398  ·  view source on GitHub ↗
(self, pid)

Source from the content-addressed store, hash-verified

3385 return rss
3386
3387 def get_process_info_by_pid(self, pid):
3388 process_info = {}
3389 try:
3390 if not os.path.exists('/proc/{}'.format(pid)): return process_info
3391 p = psutil.Process(pid)
3392 status_ps = {'sleeping': '睡眠', 'running': '活动'}
3393 with p.oneshot():
3394 process_info['memory_used'] = self.get_proc_rss(pid)
3395 process_info['cpu_percent'] = self.get_cpu_precent(p)
3396 return process_info
3397 except:
3398 return process_info
3399
3400 def get_cpu_precent(self, p):
3401 '''

Callers 1

get_mem_and_cpuMethod · 0.95

Calls 4

get_proc_rssMethod · 0.95
get_cpu_precentMethod · 0.95
existsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected