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
  • 695
  • 3
  • 10
  • 21

2 Answers2

5

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

Jeremiah
  • 1,419
  • 8
  • 16
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
  • 16,565
  • 9
  • 48
  • 68
pyfunc
  • 63,167
  • 15
  • 145
  • 135