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

memory leak using scapy sessions

Currently experiencing high memory usage by scapy 2.4.0 on python 2.7 running on centos 7.4 originally I thought it was due to https://bitbucket.org/secdev/scapy/issues/5149/rdpcap-and-wrpcap-file-descriptor-leak but this was was fixed some time…
bain2236
  • 111
  • 1
  • 9
1
vote
0 answers

How to get parent process id from service pid using psutil in python 3

I have two windows services "abc" and "xyz". I want to find out parent process id of each services. But every time parent process id is same for both services. what I have done so far.. service1 = psutil.win_service_get('abc') service2 =…
ARi
  • 78
  • 14
1
vote
1 answer

how to make this code more efficient with selenium and python

hello i have written the below code to visit a website throw a proxy and click a button and then close the browser and repeat the about sets however with a different proxy. however the browser is not closing so there is a build up browsers. here is…
koolkid
  • 13
  • 3
1
vote
1 answer

Get all processes using a file in Python

I'd like to find an efficient way to get all the processes using a particular file. I know I can do psutil.process_iter() and then search process.open_files for the file for each process. This is very inefficient as searching every single process,…
Daniel Paczuski Bak
  • 3,720
  • 8
  • 32
  • 78
1
vote
1 answer

ModuleNotFoundError: No module named 'getpwnam'

I want to use the following code to change the owner of files: import os from getpwnam import pwd from getgrnam import grp uid = getpwnam('edamame')[2] gid =…
Edamame
  • 23,718
  • 73
  • 186
  • 320
1
vote
1 answer

subprocess and psutil : how to get a list out of subprocess.check_output?

I am willing to determine the current CPU usage of a bunch of Linux computers, all available via SSH connexion. As for now I have managed something via the psutil and subprocess modules, but it could be much more straightforward if I could get a…
jeannej
  • 1,135
  • 1
  • 9
  • 23
1
vote
1 answer

How To Kill Process With Minimum Processor Consumption

I was looking for a python script to kill particular running process(s). I got a script to get list of all currently running processes. So I did some modifications and it works as follows: A list named blackList stores all the unwanted processes…
MrEyebr0w5
  • 37
  • 7
1
vote
1 answer

measure Ethernet speed python

I am trying build Python module that will monitor and measure Ethernet speed (receive and send). This module is part of performance program. I looked for libraries that make it possible and the only library that i found is Psutil with the…
user3205436
  • 57
  • 1
  • 8
1
vote
1 answer

How to close a window in python by name

I'm making a minecraft console client script for a friend It opens the console client based on a txt file I figured out how to kill/terminate the window but this part doesn't physically close the window it just sets it to a normal command prompt…
1
vote
0 answers

Getting undesired cpu load while running a python script on cron

I am trying to run a python script in my crontab which checks the CPU load of my system and writes the result into an html file. I am calculating the cpu load using the psutil module's cpu_percent() method. When I execute the script in my jupyter…
Rajnil Guha
  • 425
  • 1
  • 4
  • 15
1
vote
1 answer

Python Convert Physical Memory to Stick Value

I am trying to convert total physical memory into stick value, ie 128gb, 64gb..etc. if I take the value of total ram from my servers, example 16826298368, and run this code I get and expected output of 16gb. Which is great. But as the memory…
scott
  • 143
  • 1
  • 2
  • 12
1
vote
0 answers

performance logging with psutil

context One Python program that uses 2 subprocesses to call other C++ programs. I would like to log how much resources used by the main and the two children individually. The option I've found so far is psutil, whereas getrusage() can't separate…
Solti
  • 633
  • 2
  • 6
  • 17
1
vote
2 answers

Error importing psutil in PyCharm Google App Engine Project

I have recently run into an import error with psutils in the types.py called from google.cloud.pubsub_v1 on a GAE standard project inside Pycharm. I messed around for a day trying to find away around it, but no go. psutil imports in python run from…
Chez
  • 961
  • 1
  • 9
  • 20
1
vote
1 answer

psutil cpu_percent v/s psutil cpu_times_percent

I am trying to write a small anomaly alarming application for my linux servers, and I found psutil to be a very handy library. However, I am not very clear about the difference between psutil.cpu_percent(interval=1) and…
sunny
  • 643
  • 2
  • 11
  • 29
1
vote
0 answers

Getting children of subprocess with shell = True

I am trying to start new command lines from script, for example: p = subprocess.Popen('start cmd /c "C:\\Program Files\\Redis\\redis-server.exe"', shell=True) And then get it's children with: p2 = psutil.Process(pid) children =…