Как упоминалось ранее, psutil
кажется лучшим инструментом для того, что вам нужно: https://github.com/giampaolo/psutil#process-management
Вот пример того, как получить данные:
from datetime import datetime
import psutil
# Getting the list of all processes (as a list, or with other attributes)
list_pids = psutil.pids()
for proc in psutil.process_iter(attrs=['pid', 'name', 'memory_percent']):
print(proc.info)
print("===SINGLE PROCESS==")
try:
notepad = subprocess.Popen("notepad.exe")
pid = notepad.pid
sleep(0.5)
# We get a "Process" from the PID
process = psutil.Process(pid)
# We can then retrieve different information on the processs
print(f"NAME: {process.name()}")
print(f"ID: {process.pid}")
print(f"STATUS: {process.status()}")
print(f"STARTED: {datetime.fromtimestamp(process.create_time())}")
print(f"CPU: {process.cpu_percent(interval=1.0)}%")
print(f"MEMORY %: {process.memory_percent():.1f}%")
finally:
notepad.kill()