安装
pip3 install psutil
获取应用pid,然后获取内存大小
get_pid_cmd = "ps -ef | grep 'test' | grep -v grep | awk '{print $2}'"
agent_memory_pid = subprocess.getoutput(get_pid_cmd)
process = psutil.Process(int(agent_memory_pid))
memory = process.memory_info().rss / 1024 / 1024 (单位是兆)