psutil
Cross-platform library for retrieving process and system monitoring information.
2. Maintained
github.com/giampaolo/psutil3. Used by agents' projects
Dependency in 117 public GitHub projects set up for AI coding agents that we scanned (1.9%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What psutil does
psutil covers the ground of a shelf of Unix commands (ps, top, free, iotop, netstat, ifconfig, lsof) from one Python module, and its Process object can set priorities, CPU affinity and resource limits as well as read them.
psutil popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How psutil is used
- psutil is a dependency in 117 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (7.2% of the 1,623 Python ones), #2 of 121 in logging, monitoring and analytics.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,137; those are left out of every share on this page.
- Projects that use it most often also use Pydantic (63.2%), Uvicorn (62.4%), FastAPI (59.8%).
- It is more common in projects set up for Continue (9.5%) than for GitHub Copilot (1.5%).
By coding agent
Often used with
psutil in practice
Strengths
The site groups the API into CPU, Memory, Disks, Network, Sensors and Processes, and all six come from the same <code>import psutil</code>. The project positions this as covering much of what <code>ps</code>, <code>top</code>, <code>netstat</code> and <code>lsof</code> do.
The site lists eight systems: Linux, Windows, macOS, FreeBSD, OpenBSD, NetBSD, Solaris and AIX. The README puts the three BSDs on one line.
The API overview shows a <code>Process</code> setting its nice value, CPU affinity and IO priority. It also sets resource limits, for example <code>p.rlimit(psutil.RLIMIT_NOFILE, (5, 5))</code>.
Besides RSS and VMS from <code>memory_info()</code>, <code>p.memory_footprint()</code> returns USS, PSS and swap. The docs annotate it as the "real" USS memory usage.
Watch out for
The main site shows the development docs. For the current release, it points to psutil.readthedocs.io/stable.
The API overview is shown "on Linux". A comment on <code>psutil.getloadavg()</code> notes that on Windows the value is emulated.
Juniper's table lists which psutil functions are supported on Junos OS with upgraded FreeBSD and on Junos OS Evolved. The Sensors row shows a dash in both columns.
Inspect one process, then list all processes
>>> import psutil
>>> 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)
>>>
>>> for p in psutil.process_iter(['pid', 'name']):
... print(p.pid, p.name())
...
1 systemd
2 kthreadd
3 ksoftirqd/0
...More about psutil
Funding
- GitHub Sponsors: https://github.com/giampaolo
- Tidelift: https://tidelift.com/funding/github/pypi/psutil
- Open Collective: https://opencollective.com/psutil
- Own page: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9ZS7PKKRM3S8
- 8 GitHub sponsors
Packages around it
- python-dotenv: .env file loading
- requests: HTTP client
- numpy: Numerical arrays
- pydantic: Data validation
- pyyaml: YAML parsing
- uvicorn: ASGI server
More in Logging, monitoring and analytics
Alternatives
psutil This page
Get started
Install it.
pip install psutilRules for your agent
## psutil
- Install with `pip install psutil`. For platform-specific details, follow https://psutil.io/install/.
- When you read several attributes of one process, put the calls inside `with p.oneshot():`, as the docs' performance section recommends.
- When you iterate over processes, pass an attrs list, e.g. `psutil.process_iter(['pid', 'name'])`, as the docs recommend.
- In `process_iter()` loops, follow Juniper's sample: wrap `proc.as_dict(attrs=[...])` in `try` / `except psutil.NoSuchProcess`.
- On Junos devices, call only the functions in Juniper's support table. It lists no sensor functions for either Junos variant.
- The docs note that `psutil.getloadavg()` on Windows is emulated.
- psutil.io documents the development version. Check psutil.readthedocs.io/stable for the current release.