Reputation: 845
I want something that will receive me the processes details, like I receive with 'ps' command in linux,
get 2 basically types- CPU usage and Memory Used.
today to get this I am using uncomfortable way:
subprocess.check_output(["ps", "aux"])
........
and parse the output of this..
any idea or solution way is acceptable!
Thanks!
Upvotes: 1
Views: 2135
Reputation: 66719
I would suggest that you use psutil
Typical usage and example for a process:
psUtilInfo - psutil.Process(pid)
cpuPercentage = int(psUtilInfo.get_cpu_percent())
memoryInfo, _vms =psUtilInfo.get_memory_info()
To get all processes
psutil.get_pid_list()
I think you can also get more information like this from this module.
Upvotes: 4