Questions tagged [psutil]

psutil (python system and process utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network) in Python.

psutil (process and system utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network) in Python. It is useful mainly for system monitoring, profiling and limiting process resources and management of running processes. It implements many functionalities offered by command line tools such as: ps, top, lsof, netstat, ifconfig, who, df, kill, free, nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap. It currently supports Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures, with Python versions from 2.6 to 3.5.

Resources:

481 questions
1
vote
2 answers

How could I find the location of a running process using Python

I need to find the location of the web-browser in the program I'm making. I've decided to do this by running a browser window then finding the path of it. I've looked at psutil but still can't figure out how to do it. I'm doing this cause I can't…
Ben
  • 49
  • 5
1
vote
1 answer

How to maximize or active a opened application window in TaskBar When the user tries to run it again?

How to view or active a application window exists in task-bar When the user tries to run it again. For Example: I have already opened MyApp application and that is already existed on task-bar and want to maximize the MyApp ,If I try to open it again…
1
vote
0 answers

Python List Comprehension (psutil)

I have used psutil to get some information about processes. I will use the code in a loop. Is it possible to use list comprehension in the following code (for faster execution)? Simplified code: import psutil list1 = [] for p in…
1
vote
0 answers

Access to process information running by others

I'm writing a program in Python to see which process is using a particular file. import psutil for i in psutil.process_iter(): print(i) print(i.open_files()) In it, I learned how to use psutil to identify the files used by process. This works…
hashito
  • 94
  • 6
1
vote
0 answers

What does psutil.cpu_percent() return? Is it the highest or lowest or average cpu usage during the time it is monitored?

I am monitoring the cpu usage of a code run. When I call cpu_percent method, what does the method return during the time frame of 2 calls of psutil.cpu_percent?- average, highest peak or lowest peak
1
vote
1 answer

Windows - file opened by another process, still can rename it in Python

On Windows OS, just before doing some actions on my file, I need to know if it's in use by another process. After some serious research over all the other questions with a similar problem, I wasn't able to find a working solution for…
Robert
  • 75
  • 9
1
vote
0 answers

Trouble pip installing psutil on Mojave

I'm trying to install psutil with the Homebrew version of Python on OSX Mojave. Running: pip3 install psutil 2> error.log The console output is: Collecting psutil Using cached psutil-5.7.2.tar.gz (460 kB) Building wheels for collected packages:…
Paradox
  • 1,935
  • 1
  • 18
  • 31
1
vote
2 answers

Results from measuring network usage with psutil and ethtool

I have an application that consumes a lot of network traffic. I used psutil to measure network activity in kbits with the following code: old_value = psutil.net_io_counters(nowrap=True).bytes_sent +…
Larrax
  • 87
  • 1
  • 8
1
vote
1 answer

how to capture the error code or error message from psutil

I have a sample python3 code below, and want to capture what kinds of error when calling psutil functions. However after running the code below, it only prints out the Error: . How can I capture the real meaningful error…
rainbirdy
  • 15
  • 2
1
vote
1 answer

getloadavg() related to the number of CPU, exceeds 100%

I am following the psutil doc to get the average system load over the last 1 minute. I am using the [x / psutil.cpu_count() * 100 for x in psutil.getloadavg()], rounded to 1 decimal place (i.e. [round(x / psutil.cpu_count() * 100, 1) for x in…
question_1
  • 102
  • 1
  • 10
1
vote
1 answer

psutil.disk_usage('/') returns weird values

When I run: >>> psutil.disk_usage('/') sdiskusage(total=451000901632, used=11184947200, free=77055238144, percent=12.7) Used is totally wrong compared to what my laptop about page says, as well as used + free != total What do each of these separate…
andriy
  • 105
  • 2
  • 8
1
vote
2 answers

psutil network monitoring script

I'm trying to create a script to monitor basic server resources:- CPU, RAM, DISK and NETWORK IN AND OUT(in mega bytes /sec). Unfortunately while the cpu, memory and disk parts work, the network function always shows 0.0 bytes in or out, even while…
Firdaus Aga
  • 27
  • 2
  • 6
1
vote
0 answers

How to get a single process ID integer from a running process in Python?

I'm currently trying to get one process id (and the id alone) from a running process, to be used later to inject a DLL into it. I had originally tried using psutil like this: def findProcessIdByName(processName): listOfProcessObjects = [] #Iterate…
anonfoxer
  • 25
  • 6
1
vote
1 answer

How to get RAM Usage percentage in Python?

Now I know there's psutil module for the use: import psutil a=psutil.virtual_memory() print(a) And it shows this output: svmem(total=4238442496, available=1836089344, percent=56.7, used=2402353152, free=1836089344) It has got percentage, but I…
SRP
  • 21
  • 4
1
vote
0 answers

Meaning of status constants of psutil Process class

I need detail description of status constants of psutil Process class. I need to define whether process is up or down based on the status returned by psutil Process. Any link describing these status clearly will be helpful. I am able to get…