1

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!

eligro
  • 785
  • 3
  • 13
  • 23

2 Answers2

5

Checkout the psutil package. I don't know of a way using strictly the stdlib.

Jeremiah
  • 1,437
  • 8
  • 17
4

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.

gecco
  • 17,969
  • 11
  • 51
  • 68
pyfunc
  • 65,343
  • 15
  • 148
  • 136