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
0
votes
0 answers

python subprocess performance analysis

I want to get the CPU and memory usage of a subprocess for performances analysis. I write this code, but I don't know if the information in my output is necessary and sufficient... import psutil import time import subprocess cmd = "python…
djangoliv
  • 1,698
  • 14
  • 26
0
votes
0 answers

Can't see what command started Windows program through python

I have a program that I start through a python program using Psutil.Popen and the program starts fine. When the program that started the windows process crashes I want to find the program through the command that I used before. If the process isn't…
Juliuszc
  • 377
  • 2
  • 4
  • 16
0
votes
4 answers

Python - find PID function using psutil - does not return anything

I have a function that should return the process ID of a given process using psutil, but for some reason it doesn't return anything. Printing the required variable shows the correct value. I think I'm doing something wrong. def…
mhd
  • 43
  • 1
  • 10
0
votes
1 answer

psutil module in python

I am a newbie in python and trying to get an understanding of psutil module. My question is that if have more than 1 instance of a process (e.g. two instances of VLC media player), does psutil.kill() kills all the instances of that process or only…
rahuljain1313
  • 141
  • 1
  • 1
  • 8
0
votes
1 answer

Strange behavior of psutil

I'm using the library psutil for python 2.7. Consider this small program : import os import psutil # return the memory usage in MB process = psutil.Process(os.getpid()) print process.memory_info().rss / float(2 ** 20) The memory informations…
Andy M
  • 5,945
  • 7
  • 51
  • 96
0
votes
1 answer

read files from linux usb drive under Windows

I use psutil , but seam the F: drive can be seen ... >>> psutil.disk_partitions() [sdiskpart(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed'), sdiskpa drom'), sdiskpart(device='E:\\', mountpoint='E:\\', fstype='', opts='cdrom'),…
0
votes
1 answer

psutil can not be found within a flask project

I have setup a fairly simple flask project. Within this flask project I want to use psutil but its not being found with the import statement. > $ ./satelite.py Traceback (most recent call…
Ne Ma
  • 1,719
  • 13
  • 19
0
votes
1 answer

Opening a file in python and tracking the pid of its default application

I need a little help with a program I'm writing. All I need it to do is launch a file in its default program and track the PID of that program (so it can be closed later). I found the following code from here: import psutil import subprocess import…
0
votes
0 answers

psutil.is_running() confusion

I want to monitor performance information of an external process, like so: resultTable = [] p = psutil.Popen(['/usr/local/bin/brew', 'doctor']) while p.is_running(): try: resultTable.append(p.memory_percent()) time.sleep(1) …
David Hall
  • 515
  • 6
  • 13
0
votes
1 answer

Killing a Windows 7 program using Python 2.7x

I currently have the below code: processlist = [] for p in psutil.process_iter(): try: process = psutil.Process(p.pid) pname = process.name() processlist.append(pname) except: …
thefragileomen
  • 1,537
  • 8
  • 24
  • 40
0
votes
0 answers

How to limit the memory used by a process using psutil?

I was wondering how to limit the memory used by a process created using subprocess.Popen with shell=True and it should also detect if the process uses more memory than allotted. Preferably I am looking for a solution using psutil. I am using python…
Quixotic
  • 2,424
  • 7
  • 36
  • 58
0
votes
1 answer

How to obtain the real number of file descriptors used by this process with psutil?

I'm currently testing the psutil API. When I run this command (in order to know the number of number of file descriptors) with: p = psutil.Process(PID) p.num_fds() I get 70 file descriptors. However, when I run this command with the same…
pi-2r
  • 1,259
  • 4
  • 27
  • 52
0
votes
1 answer

Are disk_io_counters accumulative

I'm using psutils to get disk information and I'm wondering a bit more about disk_io_counters(). Are the numbers that come back each time I make that call accumulative? Or is it the delta between the last time I called it and now? Something else?…
Gregg
  • 34,973
  • 19
  • 109
  • 214
0
votes
1 answer

How do I install the Python psutil library on a Windows XP machine without an internet connection?

I have a Windows XP machine which I'm trying to deploy to with an automated script without an internet connection. Part of my Python script requires the pymodbus3 library and though I've managed to get a lot of the required packages installed, I'm…
Jon Cage
  • 36,366
  • 38
  • 137
  • 215
0
votes
1 answer

psutil's proc.as_dict attribute "get_cpu_percent" returns 0.0 for each process

I am trying to write a very simple python script using the psutil module to return process ID, Create time, Name and CPU %. Ultimately I will use this to monitor specific thresholds based on these returned values, but for our case, I'll use a simple…
Drew Morone
  • 11
  • 1
  • 6