https://github.com/giampaolo/psutil
Cross-platform lib for process and system monitoring in Python
https://github.com/giampaolo/psutil
cpu cross-platform disk memory monitoring network processes python sensors
Last synced: about 1 month ago
JSON representation
Cross-platform lib for process and system monitoring in Python
- Host: GitHub
- URL: https://github.com/giampaolo/psutil
- Owner: giampaolo
- License: bsd-3-clause
- Created: 2014-05-23T14:01:48.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2026-10-17T16:37:34.000Z (about 1 month ago)
- Last Synced: 2026-10-18T04:21:01.806Z (about 1 month ago)
- Topics: cpu, cross-platform, disk, memory, monitoring, network, processes, python, sensors
- Language: Python
- Homepage: https://psutil.io
- Size: 39.4 MB
- Stars: 11,300
- Watchers: 224
- Forks: 1,529
- Open Issues: 281
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python - giampaolo/psutil - Cross-platform lib for process and system monitoring in Python (Utilities / Files and Operating System)
- awesome-python - psutil - Cross-platform process and system utilities module (DevOps Tools / Monitoring)
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- fucking-awesome-python-cn - psutil - :一个跨平台进程和系统工具模块。 (资源列表 / DevOps 工具)
- awesome-python-zh - psutil - 一个跨平台的进程和系统实用程序模块。 (DevOps工具)
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- python-awesome - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python-resources - GitHub - 13% open · ⏱️ 18.08.2022): (DevOps 工具)
- awesome-robotic-tooling - psutil - Cross-platform lib for process and system monitoring in Python (System / Monitoring)
- links - psutil
- awesome-robotic-tooling - psutil - Cross-platform lib for process and system monitoring in Python. (Operation System / Monitoring)
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python - psutil - Cross-platform lib for process and system monitoring in Python ` 📝 22 days ago` (DevOps Tools [🔝](#readme))
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- fucking-awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- fucking-awesome-python - :octocat: psutil - :star: 9402 :fork_and_knife: 1344 - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python-fa - psutil - مانیتورینگ منابع سیستم از جمله وضعیت شبکه. (📚 فهرست / شبکه)
- awesome-python-cn - psutil
- awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- fucking_awesome_python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- git-github.com-vinta-awesome-python - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-portantier - psutil
- jimsghstars - giampaolo/psutil - Cross-platform lib for process and system monitoring in Python (Python)
- github-ultimate-repos - giampaolo/psutil - | ⭐ 11,309★ | 🍴 1,534 | 💻 `Python`🔗 <https://github.com/giampaolo/psutil>📝 Cross-platform lib for process and system monitoring in Python⚙️ `CPython C-API binding -> vectorized NumPy ndarray broadcasting -> SIMD/BLAS numerical linear algebra -> computational pipeline execution -> serialized analytical output.` (📜 Master Categorized Repository Directory (100% Clickable Links) / [55] PYTHON ECOSYSTEM, DATA SCIENCE, SCIENTIFIC COMPUTING & ANALYTICS)
- awesome-profiling - psutil
- Python-Awesome - psutil - A cross-platform process and system utilities module. (DevOps Tools)
- awesome-python - psutil - <img src="assets/star.png" width="16" /> 4564 - Cross-platform lib for process and system monitoring in Python (Awesome Python / DevOps Tools)
README
..
.. raw:: html
..
About
=====
psutil is a cross-platform library for retrieving information about running
**processes** and **system utilization** (CPU, memory, disks, network, sensors)
in Python. It is useful mainly for **system monitoring**, **profiling**,
**limiting process resources**, and **managing running processes**. It
implements many functionalities offered by UNIX command line tool such as
*ps, top, free, iotop, netstat, ifconfig, lsof* and others (see
`shell equivalents`_). Psutil supports the following platforms:
- **Linux**
- **Windows**
- **macOS**
- **FreeBSD, OpenBSD**, **NetBSD**
- **Sun Solaris**
- **AIX**
Adoption
========
psutil is among the
`top 100 `__ most-downloaded
packages on PyPI, with **390+ million** downloads per month and **780,000+**
`GitHub repositories `__
using it. See also `adoptions `__ and
`alternatives `__.
Install
=======
.. code-block::
pip install psutil
For platform-specific details see `installation `_.
Documentation
=============
psutil documentation is available at https://psutil.io.
..
Sponsors
========
.. raw:: html
..
Example usages
==============
For the full API with more examples, see the
`API overview `_ and
`API reference `_.
**CPU**
.. code-block:: python
>>> import psutil
>>> psutil.cpu_percent(interval=1, percpu=True)
[4.0, 6.9, 3.7, 9.2]
>>> psutil.cpu_count(logical=False)
2
>>> psutil.cpu_freq()
scpufreq(current=931.42, min=800.0, max=3500.0)
**Memory**
.. code-block:: python
>>> psutil.virtual_memory()
svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, ...)
>>> psutil.swap_memory()
sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944)
**Disks**
.. code-block:: python
>>> psutil.disk_partitions()
[sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'),
sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext', opts='rw')]
>>> psutil.disk_usage('/')
sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5)
**Network**
.. code-block:: python
>>> psutil.net_io_counters(pernic=True)
{'eth0': netio(bytes_sent=485291293, bytes_recv=6004858642, ...),
'lo': netio(bytes_sent=2838627, bytes_recv=2838627, ...)}
>>> psutil.net_connections(kind='tcp')
[sconn(fd=115, family=2, type=1, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED', pid=1254),
...]
**Sensors**
.. code-block:: python
>>> psutil.sensors_temperatures()
{'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0),
shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0)]}
>>> psutil.sensors_battery()
sbattery(percent=93, secsleft=16628, power_plugged=False)
**Processes**
.. code-block:: python
>>> p = psutil.Process(7055)
>>> p.name()
'python3'
>>> p.exe()
'/usr/bin/python3'
>>> p.cpu_percent(interval=1.0)
12.1
>>> p.memory_info()
pmem(rss=3164160, vms=4410163, shared=897433, text=302694, data=2422374)
>>> p.net_connections(kind='tcp')
[pconn(fd=115, family=2, type=1, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED')]
>>> p.open_files()
[popenfile(path='/home/giampaolo/monit.py', fd=3, position=0, mode='r', flags=32768)]
>>>
>>> for p in psutil.process_iter(['pid', 'name']):
... print(p.pid, p.name())
...
1 systemd
2 kthreadd
3 ksoftirqd/0
...
.. _`shell equivalents`: https://psutil.io/shell-equivalents/
..
License
=======
BSD-3